问题描述
我在使用 .NET Core 2.2 和 sql Always Encrypted 时收到以下错误。这在 2.2 中支持吗?
不支持关键字:'列加密设置'。
实际上,我在 AppContext 构造函数中运行数据库迁移,正如您在那里看到的那样。
public SenSightsContext(DbContextOptions<SenSightsContext> options)
: base(options)
{
Database.Migrate();
}
它以前不起作用,它给了我一个例外,我通过安装 Microsoft.Data.sqlClient 修复了这个问题。 现在它给了我 SeedData 方法的错误,如下所示。
public void Configure(IApplicationBuilder app,IHostingEnvironment env,RoleManager<ApplicationRole> roleManager,AppUserManager userManager,ILoggerManager loggerManager)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
// The default HSTS value is 30 days. You may want to change this for production scenarios,see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
//custom exception middleware.
app.ConfigureExceptionHandler(loggerManager);
//Seed Data
SeedData(roleManager,userManager).Wait();
// global cors policy
app.UseCors(x => x
.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader());
app.UseAuthentication();
app.UseHttpsRedirection();
// Enable middleware to serve generated Swagger as a JSON endpoint.
app.UseSwagger();
// Enable middleware to serve swagger-ui (HTML,JS,CSS,etc.),// specifying the Swagger JSON endpoint.
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json","SenSights API V1");
//c.RoutePrefix = string.Empty; // Set Swagger UI at apps root
});
var path = Path.Combine(env.ContentRootPath,"Uploads","ProfileImages");
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
app.UseStaticFiles(new StaticFileOptions
{
FileProvider = new PhysicalFileProvider(path),RequestPath = "/ProfileImages"
});
app.UseMvc();
}
以下是堆栈
在 System.Data.sqlClient.sqlConnectionStringBuilder.GetIndex(String 关键字)
在 System.Data.sqlClient.sqlConnectionStringBuilder.set_Item(String 关键字,对象值)
在 System.Data.Common.DbConnectionStringBuilder.set_ConnectionString(String value)
在 System.Data.sqlClient.sqlConnectionStringBuilder..ctor(String connectionString)
在 Microsoft.EntityFrameworkCore.sqlServer.Storage.Internal.sqlServerConnection.get_IsMultipleActiveResultSetsEnabled()
在 Microsoft.EntityFrameworkCore.Storage.RelationalConnection.d__61.MoveNext()
在 System.Runtime.ExceptionServices.ExceptiondispatchInfo.Throw()
在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
在 Microsoft.EntityFrameworkCore.Query.Internal.AsyncQueryingEnumerable1.AsyncEnumerator.<BufferlessMoveNext>d__12.MoveNext() at System.Runtime.ExceptionServices.ExceptiondispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.EntityFrameworkCore.sqlServer.Storage.Internal.sqlServerExecutionStrategy.<ExecuteAsync>d__7
2.MoveNext()
在 System.Runtime.ExceptionServices.ExceptiondispatchInfo.Throw()
在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
在 System.Runtime.CompilerServices.TaskAwaiter1.GetResult() at Microsoft.EntityFrameworkCore.Query.Internal.AsyncQueryingEnumerable
1.AsyncEnumerator.d__11.MoveNext()
在 System.Runtime.ExceptionServices.ExceptiondispatchInfo.Throw()
在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
在 System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult() at System.Linq.AsyncEnumerable.<FirstOrDefault_>d__165
1.MoveNext() 在 D:\a\1\s\Ix.NET\Source\system.interactive.Async\First.cs:line 151
在 System.Runtime.ExceptionServices.ExceptiondispatchInfo.Throw()
在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
在 System.Runtime.CompilerServices.TaskAwaiter1.GetResult() at Microsoft.EntityFrameworkCore.Query.Internal.AsyncLinqOperatorProvider.TaskResultAsyncEnumerable
1.Enumerator.d__3.MoveNext()
在 System.Runtime.ExceptionServices.ExceptiondispatchInfo.Throw()
在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
在 System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult() at System.Linq.AsyncEnumerable.SelectEnumerableAsyncIterator
2.d__7.MoveNext() 在 D:\a\1\s\Ix.NET\Source\system.interactive.Async\Select.cs:line 118
在 System.Runtime.ExceptionServices.ExceptiondispatchInfo.Throw()
在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
在 System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult() at System.Linq.AsyncEnumerable.AsyncIterator
1.d__10.MoveNext() 在 D:\a\1\s\Ix.NET\Source\system.interactive.Async\AsyncIterator.cs:line 112
在 System.Runtime.ExceptionServices.ExceptiondispatchInfo.Throw()
在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
在 System.Runtime.CompilerServices.TaskAwaiter1.GetResult() at Microsoft.EntityFrameworkCore.Query.Internal.AsyncLinqOperatorProvider.ExceptionInterceptor
1.EnumeratorExceptionInterceptor.d__5.MoveNext()
在 System.Runtime.ExceptionServices.ExceptiondispatchInfo.Throw()
在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
在 System.Runtime.CompilerServices.TaskAwaiter1.GetResult() at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<ExecuteSingletonAsyncQuery>d__21
1.MoveNext()
在 System.Runtime.ExceptionServices.ExceptiondispatchInfo.Throw()
在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
在 System.Runtime.CompilerServices.TaskAwaiter1.GetResult() at Microsoft.AspNetCore.Identity.RoleManager
1.d__33.MoveNext()
在 System.Runtime.ExceptionServices.ExceptiondispatchInfo.Throw()
在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
在 System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
在 C:\WorkSpaces\Markitech\Sensight\sensights_backend\SenSights-API\Startup.cs:line 256
任何帮助将不胜感激 谢谢
解决方法
需要添加以下包引用 Microsoft.Data.SqlClient(参见 nuget)并使用此 Microsoft.Data.SqlClient 而不是 System.Data.SqlClient。
.NET Core 3.0+ 版本支持