简体   繁体   中英

Ubuntu 16.10 and .net core MVC Web app

I try run asp.net core mvc web application with individual authorize, on Ubuntu 16.10. I have installed and succesfully set nginx. I can restore and run mvc app on this server, but I have problem with registration and login, seems to be problem with database. Web app is simply web with registration and login of users. This web app was created in Visual Studio 2017, but if I tried create Web app on Ubuntu result was same. Can you help please? So there is info:

.NET Command Line Tools (1.0.3)

Product Information: Version: 1.0.3

Runtime Environment:

OS Name: ubuntu

OS Version: 16.10

OS Platform: Linux

RID: ubuntu.16.10-x64

Base Path: /usr/share/dotnet/sdk/1.0.3

There is a error: fail: Microsoft.EntityFrameworkCore.Query.Internal.SqlServerQueryCompilationContextFactory[1] An exception occurred in the database while iterating the results of a query. System.NotSupportedException: The keyword 'integrated security' is not supported on this platform. at System.Data.SqlClient.SqlConnectionString..ctor(String connectionString) at System.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(String connectionString, DbConnectionOptions previous) at System.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(DbConnectionPoolKey key, DbConnectionPoolGroupOptions poolOptions, DbConnectionOptions& userConnectionOptions) at System.Data.SqlClient.SqlConnection.ConnectionString_Set(DbConnectionPoolKey key) at System.Data.SqlClient.SqlConnection.set_ConnectionString(String value) at Microsoft.EntityFrameworkCore.Storage.Internal.SqlServerConnection.CreateDbConnection() at Microsoft.EntityFrameworkCore.Internal.LazyRef`1.get_Value() at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.d__31.MoveNext()

If look at connection string specified in the appSettings.json, it refers the (localdb)\\mssqllocaldb,Trusted_Connection=True; I'm not sure whether it supports mssqllocaldb, on top of it's looking for integrated security of the user who logged in.

So, in order to avoid the issue in either mac/ubuntu, we can change the db to either use in memory database (it will work if there is no migration you have to run) or sqllite database.

/* In case if you want to run dotnet ef database update */
services.AddDbContext<ApplicationDbContext>(options =>
                options.UseSqlite("Data Source=CM-starter-4")); 


/* or else */
    services.AddDbContext<ApplicationDbContext>(options =>
                    options.UseInMemoryDatabase());

In order to make use of those, we can refer either one of those packages based on our requirement in the .csproj file.

 <PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="1.1.0" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="1.1.0" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM