从 VS Community 2017 MVC 5 项目运行 dacpac 时出现此错误。
"Internal Error. The database platform service with type Microsoft.Data.Tools.Schema.Sql.Sql140DatabaseSchemaProvider is not valid. You must make sure the service is loaded, or you must provide the full type name of a valid database platform service."
编码
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
};
var dbServices = new DacServices(setupDbConn.ConnectionString);
dbServices.Deploy(dp, newDatabaseName, true, dbDeployOptions);
错误发生在此代码之后:
var dbServices = new DacServices(setupDbConn.ConnectionString);
我的 SqlExpress 是 2017 年。我也从 SqlExpress 2017 重新生成了 dacpac。当我在 SqlExpress 中使用 dacpac 时,它可以正常工作。
我已经在谷歌上搜索了几个小时,但似乎找不到正确的答案。我认为这是某种兼容性问题,但无法弄清楚如何解决该错误。
希望有人经历过这个,可以帮助我解决这个问题。