当我添加 sql 数据库时,我在 Startup.cs 中收到一个错误,我不知所措。我输入:
services.AddDbContext<ModelContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DatabaseConnection")));
Run Code Online (Sandbox Code Playgroud)
好吧,我实际上是从 program.cs 中得到的,但错误源自上面的行。呼叫者:
var context = services.GetRequiredService<ModelContext>();
Run Code Online (Sandbox Code Playgroud)
错误信息是:
Method 'Clone'
in type 'Microsoft.EntityFrameworkCore.Infrastructure.Internal.SqlServerOptionsExtension'
from assembly 'Microsoft.EntityFrameworkCore.SqlServer, Version=1.1.5.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' does not have an implementation.
Run Code Online (Sandbox Code Playgroud)
错误来源是:
Microsoft.EntityFrameworkCore.SqlServer
Run Code Online (Sandbox Code Playgroud)
完整的错误信息:
+ Data {System.Collections.ListDictionaryInternal} System.Collections.IDictionary {System.Collections.ListDictionaryInternal}
HResult -2146233054 int
HelpLink null string
+ InnerException null System.Exception
Message "Method 'Clone' in type 'Microsoft.EntityFrameworkCore.Infrastructure.Internal.SqlServerOptionsExtension' from assembly 'Microsoft.EntityFrameworkCore.SqlServer, Version=1.1.5.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' does not have an implementation." string
Source "Microsoft.EntityFrameworkCore.SqlServer" string
StackTrace " at Microsoft.EntityFrameworkCore.SqlServerDbContextOptionsExtensions.UseSqlServer\r\n at FltCandidates.Startup.<ConfigureServices>b__4_0(DbContextOptionsBuilder options) in C:\\Users\\garry\\source\\repos\\FltCandidates\\FltCandidates\\Startup.cs:line …Run Code Online (Sandbox Code Playgroud)