Entity framework core 无法加载DLL';sni.dll';或其依赖项之一:访问被拒绝。(0x80070005(E_访问被拒绝))

Entity framework core 无法加载DLL';sni.dll';或其依赖项之一:访问被拒绝。(0x80070005(E_访问被拒绝)),entity-framework-core,Entity Framework Core,我正在尝试将实体框架核心3.1.7(代码优先)与SQLServerExpress结合使用 添加迁移效果很好,但当我尝试迁移到数据库时 System.TypeInitializationException: The type initializer for 'Microsoft.Data.SqlClient.TdsParser' threw an exception. ---> System.TypeInitializationException: The type initializer

我正在尝试将实体框架核心3.1.7(代码优先)与SQLServerExpress结合使用

添加迁移效果很好,但当我尝试迁移到数据库时

System.TypeInitializationException: The type initializer for 'Microsoft.Data.SqlClient.TdsParser' threw an exception.
 ---> System.TypeInitializationException: The type initializer for 'Microsoft.Data.SqlClient.SNILoadHandle' threw an exception.
 ---> System.DllNotFoundException: Unable to load DLL 'sni.dll' or one of its dependencies: Access is denied. (0x80070005 (E_ACCESSDENIED))
   at Microsoft.Data.SqlClient.SNINativeMethodWrapper.SNIInitialize(IntPtr pmo)
   at Microsoft.Data.SqlClient.SNINativeMethodWrapper.SNIInitialize()
   at Microsoft.Data.SqlClient.SNILoadHandle..ctor()
   at Microsoft.Data.SqlClient.SNILoadHandle..cctor()
   --- End of inner exception stack trace ---
   at Microsoft.Data.SqlClient.TdsParserStateObjectFactory.get_EncryptionOptions()
   at Microsoft.Data.SqlClient.TdsParser..cctor()
   --- End of inner exception stack trace ---
如果我查找该文件,它位于..\bin\Debug\netcoreapp3.1\runtimes\win-x64\native下\

顺便说一句
我确实尝试过安装Microsoft.Data.SqlClient Nuget软件包,但在一天半之后,我发现了相同的错误。正是连接字符串(我使用的是SQL Server Express)改变了计算机名的“localhost”,它才起作用