azure - .NET Core 关键字不支持 : 'server'

标签 azure sqlite asp.net-core

下页上的示例应用程序无法启动。 https://learn.microsoft.com/en-us/azure/app-service/tutorial-dotnetcore-sqldb-app?pivots=platform-linux https://github.com/azure-samples/dotnetcore-sqldb-tutorial

如文档中所述 下载示例应用程序并创建要连接的数据库后,执行数据库迁移时会出现错误。

$ export ConnectionStrings__MyDbConnection="Server=tcp:db-host.database.windows.net,1433;Database=coreDB;User ID=<username>;Password=<password>;Encrypt=true;Connection Timeout=30;"
$ dotnet ef database update
Build started...
Build succeeded.
info: Microsoft.EntityFrameworkCore.Infrastructure[10403]
      Entity Framework Core 3.1.3 initialized 'MyDatabaseContext' using provider 'Microsoft.EntityFrameworkCore.Sqlite' with options: None
System.ArgumentException: Keyword not supported: 'server'.
   at Microsoft.Data.Sqlite.SqliteConnectionStringBuilder.GetIndex(String keyword)
   at Microsoft.Data.Sqlite.SqliteConnectionStringBuilder.set_Item(String keyword, Object value)
   at System.Data.Common.DbConnectionStringBuilder.set_ConnectionString(String value)
   at Microsoft.Data.Sqlite.SqliteConnectionStringBuilder..ctor(String connectionString)
   at Microsoft.EntityFrameworkCore.Sqlite.Storage.Internal.SqliteDatabaseCreator.Exists()
   at Microsoft.EntityFrameworkCore.Migrations.HistoryRepository.Exists()
   at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.Migrate(String targetMigration)
   at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.UpdateDatabase(String targetMigration, String contextType)
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabaseImpl(String targetMigration, String contextType)
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabase.<>c__DisplayClass0_0.<.ctor>b__0()
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
Keyword not supported: 'server'.

你知道原因吗? 我正在使用 .NET Core 3.1。

最佳答案

如果您确实打算使用 SQLite,那么您应该检查以下连接字符串模式:

https://learn.microsoft.com/en-us/dotnet/standard/data/sqlite/connection-strings

如果没有,您的代码会意外调用 SQLite 扩展来配置您的 DbContext...执行完整搜索 (Ctrl+Shift+F)在 UseSqlite 方法的整个解决方案中,并将其替换为所需的数据库提供程序扩展(可能需要对您的项目进行新的包引用)

关于azure - .NET Core 关键字不支持 : 'server' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68887171/

相关文章:

Azure函数错误: "Your function app does not support remote build..."

sql - VB.Net写入大量数据到SQLite-DB

ruby-on-rails - RoR/Heroku : detected sqlite3 gem which is not supported on heroku

android - 如何按desc顺序从sqlite中检索数据并在textview中显示

asp.net-core - 点网核心 : What are the sha512 and shaPath properties used for in . deps.json

razor - Razor页面在运行时无法在ASP.NET Core RC2中看到引用的类库

asp.net-core - .NET 5 Web API : Storing data per request

azure - ARM 模板中的 KeyVault 引用存在问题

performance - Azure 表存储分区单独性能

azure - 如何在 azure 上打开 websocket 端口?