【问题标题】:EF Code First - run Update-Database from Azure portalEF Code First - 从 Azure 门户运行更新数据库
【发布时间】:2018-04-27 10:35:30
【问题描述】:

我目前正在寻找在 Azure 上更新我们的数据库的最佳方式。运行 Visual Studio 来运行“Update-Database”命令似乎有点麻烦。有没有办法部署到 Azure,然后从 Azure 门户运行“Update-Database”命令?或者这只是更新生产数据库时的标准方式?

【问题讨论】:

    标签: c# azure azure-sql-database


    【解决方案1】:

    我不确定直接从 azure 门户运行 powershell 命令。

    但是,您可以使用 System.Data.Entity.MigrateDatabaseToLatestVersion 自动为您执行此操作,以便部署到 azure。如果您在发布配置文件向导中选择更新数据库,这可以自动添加到您的 web.config。可以在此处找到有关如何执行此操作的详细信息

    https://docs.microsoft.com/en-us/aspnet/mvc/overview/getting-started/getting-started-with-ef-using-mvc/migrations-and-deployment-with-the-entity-framework-in-an-asp-net-mvc-application

    https://msdn.microsoft.com/en-us/library/hh829293(v=vs.113).aspx

    【讨论】:

      【解决方案2】:

      如前所述,您可以将应用程序设置为在启动时自动将新迁移应用到数据库。

      另一种方法是使用 Visual Studio Team Services 设置发布过程,然后使用 powershell 设置数据库迁移。此处提供了一些详细信息:VSTS Build Task that runs script on multiple shards

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多