I have an application which uses Entity Framework Code First models.
The structure of the project looks like this
- Application.Models POCO objects
- Application.EF EF Data Context and repositories
- Application.Web.MVC The web application (the designer)
The context initializer looks like this:
public class DBContextInitializer : DropCreateDatabaseIfModelChanges<DBContext>
{
protected override void Seed(DBContext context)
{
}
}
Now, i have another API Application which gets the data from database as API calls. The project looks like this:
- Application.Api.MVC The MVC4 API Project, containing DTO objects
- Application.Models Same project
- Application.EF Same project
Even if i don’t change the POCO classes (inside Application.Models project), Entity Framework detects that the Metadata has changed, and tries to drop and re-create the database. If it does it, when i run the Designer Application (Application.Web.MVC), it drops it again, and so on.
I don’t know why is it doing this. I am not changing the models.
Please ignore the question, it is all working. I was pointing to a different database.
Also, this was a good reason to learn about EF Migrations