Frage

I understand database migrations might not be the best method to deploy this solution, so any suggestions would be greatly appreciated.

I have x identical database schemas, one per client.

I also have models for each one of these databases and am able to deploy a migration which creates a new clone. Up until this point, I had been using PHP and scripts to loop through all the schemas and update any changes to the structure. We are moving over to C# and EF6 due to Web API 2 and attribute routing.

My question is; Is there a way to:

  1. Deploy a build command which will do what update-database would do for a migration, and pass it a database name (in order to create a new clone schema of the account database?

  2. Deploy a build command which might do what update-database would do recursively through each one of the target databases?

War es hilfreich?

Lösung

"I have x identical database schemas, one per client "
and
"I also have models for each one of these databases"

Did you mean I also have models for each one of these Schemas?

Ef model entities are linked to a Schema/TableName.

entity.ToTable("tableName", "schemaName");

So if each client gets their own schema, then each model has all tables in that schema and the client gets their own model. So how do I run update-database on each Context model. I another way of looking at the issue.

So the answer lies with how you are tracking the schema per client info.

Powershell migrate.exe approach might be interest for your so that you can trigger migration on many context models.

Custom migration operations might also be interesting. Rowan is an EF developer.

EDIT: based on Auto Migration comment, this is worth a look Managing migration triggers in code

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top