简体   繁体   English

Ubuntu 16.10和.net核心MVC Web应用

[英]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. 我尝试在Ubuntu 16.10上运行具有单独授权的asp.net核心mvc Web应用程序。 I have installed and succesfully set nginx. 我已经安装并成功设置了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. 我可以在此服务器上还原并运行mvc应用程序,但是注册和登录时出现问题,似乎是数据库问题。 Web app is simply web with registration and login of users. Web应用程序就是具有用户注册和登录权限的简单Web。 This web app was created in Visual Studio 2017, but if I tried create Web app on Ubuntu result was same. 该Web应用程序是在Visual Studio 2017中创建的,但是如果我尝试在Ubuntu上创建Web应用程序,结果是相同的。 Can you help please? 你能帮忙吗? So there is info: 所以有信息:

.NET Command Line Tools (1.0.3) .NET命令行工具(1.0.3)

Product Information: Version: 1.0.3 产品信息:版本:1.0.3

Runtime Environment: 运行环境:

OS Name: ubuntu 操作系统名称:ubuntu

OS Version: 16.10 操作系统版本:16.10

OS Platform: Linux 操作系统平台:Linux

RID: ubuntu.16.10-x64 RID:ubuntu.16.10-x64

Base Path: /usr/share/dotnet/sdk/1.0.3 基本路径:/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. 有一个错误:失败:Microsoft.EntityFrameworkCore.Query.Internal.SqlServerQueryCompilationContextFactory [1]在迭代查询结果时数据库中发生了异常。 System.NotSupportedException: The keyword 'integrated security' is not supported on this platform. System.NotSupportedException:在此平台上不支持关键字“集成安全性”。 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() 在System.Data.SqlClient.SqlConnectionString..ctor(字符串connectionString)在System.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(字符串connectionString,DbConnectionOptions以前)在System.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(DbConnectionPoolKey键,DbConnectionPoolGroupOptions poolOptions,DbConnectionOptions& Microsoft.EntityFrameworkCore.Storage.Internal.SqlServerConnection.CreateDbConnection()的System.Data.SqlClient.SqlConnection.set_ConnectionString(String值)的System.Data.SqlClient.SqlConnection.ConnectionString_Set(DbConnectionPoolKey键) Microsoft.EntityFrameworkCore.Storage.RelationalConnection.d__31.MoveNext()上的.LazyRef`1.get_Value()

If look at connection string specified in the appSettings.json, it refers the (localdb)\\mssqllocaldb,Trusted_Connection=True; 如果查看appSettings.json中指定的连接字符串,它将引用(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. 我不确定它是否支持mssqllocaldb,此外,它还在寻找登录用户的集成安全性。

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. 因此,为了避免在mac / ubuntu中出现此问题,我们可以将db更改为在内存数据库中使用(如果没有必须运行的迁移,它将起作用)或sqllite数据库。

/* 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. 为了利用这些,我们可以根据.csproj文件中的要求引用其中一个软件包。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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