我正在尝试在SQL Server Express中使用Entity Framework Core 3.1.7 (代码优先)。
添加-迁移工作得很好,但是当我尝试迁移到数据库时
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包,但得到相同的错误不同
发布于 2020-08-19 05:16:09
一天半后,我想通了。这是连接字符串(我使用的是SQL Server Express),我更改了'localhost‘作为计算机的名称,它起作用了。
https://stackoverflow.com/questions/63474183
复制相似问题