EF migration utility seems quite nice when using code first.
Based on this blog post, I tried setting it in my project where we use model-first. When running Enable-Migrations
command, I get the following error:
Creating a DbModelBuilder or writing the EDMX from a DbContext created using Database First or Model First is not supported. EDMX can only be obtained from a Code First DbContext created without using an existing DbCompiledModel.
Is there any way around it so we can use the EF migration without switching to code-first?
I have an incomplete blog entry on how you could do this. Not sure if it will fit your need, but seems to be the only method available so far.
Basically you use custom t4 to generate DbMigrationsConfiguration and DbContext from your model and you don't need to run Enable-Migration at all. Simply run Add-Migration and Update-Database in the Package Manager Console.
http://blog.amusedia.com/2012/08/entity-framework-migration-with-model.html
I will be update the blog entry and t4 to make it more user friendly later.
I was looking for the same solution and found this: Entity Designer Database Generation Power Pack After installation, when you choose "Generate Database from Model..." it'll popup a new wizard and you can choose "Generate Migration T-SQL".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With