Support for script generation using Migrations residing in external DLL RRS feed

  • General discussion

  • Hello there,
    I am working on developing certain core functional Web API packages for distribution within my organization. Its more like a blueprint that people can get from organization's nuget repo and host a customized instance of a specific service with minimum configuration. This would also need database migrations, however, I want to distribute migrations via another central package as well. People should not be able to customize the database and database should stick to the centralized schema or updates I make and distribute via nuget.

    The idea is, teams would download the WebApi package and the migrations package. They would do some minimum configuration and setup the WebApi. They would run the following command to generate db scripts that they can use to host their own databases:

    Update-Database -Script -ConfigurationTypeName MyCompany.MyApi.Data.SomeDbConfiguration -ConfigurationSourcePackage MyCompany.MyApi.Data.dll

    (the ConfigurationSourcePackage switch is something I made up just to emphasize what I am trying to acoomplish)

    With that, no body ever needs to bother about a Data project, they just generate scripts from the package and update their databases, use a connection string and only focus on the functional customization of the WebApi according to their needs.

    This way I can keep a the Database Migrations complexity away from teams and also make sure everyone is on the same version.

    The Update-Database -Script command only works on actual projects that exists in the current opened solution and not external libraries that might contain the Configurations and Migrations. I have seen people do tedious workarounds for this but I wish this was made part of the EntityFramework itself.

    Please add this feature to externalize DbContexts, Configurations and Migrations in EntityFramework.

    Thursday, March 16, 2017 7:09 PM