Automatically execute migrations when publishing ASP.NET Core app

后端 未结 4 1189
难免孤独
难免孤独 2020-12-16 23:19

Question

Is there any ways that I can automatically execute the migration code (EF 7) when publishing my ASP 5 application to IIS using Web Deploy?<

4条回答
  •  猫巷女王i
    2020-12-17 00:04

    So I added the option -environment to my ef database command. Now it works:

    "postpublish": ["dnx ef database update -e Staging"]
    

    I have four different appsettings.json which different connection string for each environment. Just needed to indicate the environment for the command to work.

提交回复
热议问题