Entity Framework migration Model First

c# entity-framework entity-framework-6 sql-server

Question

I used the database's tables to build an EDMX model. I want to make some changes to my model right now, and then I want to update the database.

I've read that in order to do this, I must run the enable-migrations command in the nuget terminal. I encounter the following error when I run the command.

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.

What I want to do is make changes to the model while it is being developed, have it automatically sync with the database, and then run some SQL scripts once the migration from the model to the database has taken place. However, I keep getting the issue that I have already showed you.

1
2
2/26/2015 5:44:20 PM

Popular Answer

Model first and migrations are incompatible. You might create a script using the schema compare tool in some versions of Visual Studio by typing https://msdn.microsoft.com/en-us/library/hh272690(v=vs.103).aspx.

If not, you might apply Code First to an existing database as follows: http://weblogs.asp.net/scottgu/using-ef-code-first-with-an-existing-database#7579835

2
2/26/2015 9:17:37 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow