We are using a different database schema name for each environment (e.g. "dev", "test", "prod"), and I'm trying to setup Migrations with Entity Framework Core.
The first thing I did was Add-Migration Init
, which as expected created a Migration for the initial schema. However, this Migration hard-codes the schema name:
migrationBuilder.EnsureSchema(
name: "dev");
migrationBuilder.CreateTable(
name: "MyTable",
schema: "dev",
columns: table => new
...
I guess I could modify the Migration files generated by dotnet ef
to use a schema name based on an environment variable, but I'd rather not modify these auto-generated files if possible.
Is there any other way to use an environment-specific schema name?