Entity framework has three initializers I'm aware of - CreateDatabaseIfNotExists
, DropCreateDatabaseWhenModelChanges
and DropCreateDatabaseAlways
. When model changes, they either drop all data, or die.
I want an initializer that would extent the existing database to match the model. If a table is missing, create it, if some columns changed, rename them and make new copies, etc. Naturally, there is a lot to be considered, in particular when it comes to references, but I'm sure something more sensible than dropping the data can be done.
Does such initializer exist? If not, how could I write one?
To clarify, I want to read the changes detected by EF, and if, say, a column changed from int
to double
, I want to make the change while preserving my data. Complex interactions between reference columns don't need to be considered.