Base solution for your next web application
Open Closed

Updating Database via code without Migrator application #10051


User avatar
0
CrayonGroupSCA created

Using: 7.2 MVC .Net Core

Hi, We are looking to have EF automatically update the database when the code runs without relying on the manual "update-database" from package manager console. Our project deploys via Azure DevOps nightly (dev / uat etc), but we have been told they can't support adding 3rd party components and I have been advised on updating the database via code instead.

I've looked thru the other articles and there have been a couple on this topic over the years, but they have been along the lines of "copy code from the migrator app" which hasn't proven sucessful.

Is it possible to get clearer guidance on how we can do this and where? Our developers previous attempt resulted in reference errors from trying to combine segments of two different projects and think a clear example of what to do would benefit others that are looking to automate database upgrades without relying on other platforms to do it.

Any guidance would be most welcome. Thanks, Dave


1 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @CrayonGroupSCA

    You can easily use Migrator project to update your database on Azure. You need to publish the Migrator app in your pipeline, copy its output to a directory under your website and run it there.

    We were executing Migration in the way you explaind before but it causes app to slow down at initialization. However, if you still want to use this approach, you can execute MultiTenantMigrateExecuter in the PostInitialize of your EntityFrameworkModule.