.Net MVC deploy a dacpac

谁说胖子不能爱 提交于 2019-12-25 00:31:01

问题


I'm trying to do deploy dacpac. I'm having errors though when running below code.

            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
            };

When running the code I'm encountering the error:

The type initializer for 'Microsoft.SqlServer.Dac.DacPackage' threw an exception.

This happens just right after the:

 var dp = DacPackage.Load(dacpacPath);

My path is:

var dacpacPath = Path.Combine(Server.MapPath("~/assets/dacpac"), dacpacName);

So the path is pointing to the exact location of the dacpac file but it's not working.


回答1:


Found the answer to my question from https://social.msdn.microsoft.com/Forums/sqlserver/en-US/ced08955-1d00-48cd-a3fc-905e4fd07f43/error-installing-dacpac-using-sqlpackageexe?forum=ssdt

I search the ff from nuget and installed it, and the error is gone.

  • T-SQL ScriptDom
  • SQLSysCLRTypes

Thanks,



来源:https://stackoverflow.com/questions/54545820/net-mvc-deploy-a-dacpac

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!