我试图做部署dacpac。下面的代码运行时,虽然我有错误。
var dacpacName = "Setup.dacpac";
var dacpacPath = Path.Combine(Server.MapPath("~/assets/dacpac"), dacpacName);
var dp = DacPackage.Load(dacpacPath);
var dbDeployOptions = new DacDeployOptions
{
BlockOnPossibleDataLoss = false,
ScriptDatabaseOptions = false,
GenerateSmartDefaults = true,
CreateNewDatabase = true
};
当运行代码,我遇到的错误:
The type initializer for 'Microsoft.SqlServer.Dac.DacPackage' threw an exception.
发生这种情况后,刚刚好:
var dp = DacPackage.Load(dacpacPath);
我的路径是:
var dacpacPath = Path.Combine(Server.MapPath("~/assets/dacpac"), dacpacName);
因此,路径指向dacpac文件的确切位置,但它不工作。
我搜索从的NuGet FF和安装,并且错误消失。
谢谢,