Search code examples
ef-code-firstentity-framework-4.1

EF 4.1 Code First and Existing Database and .NET Membership


I have a database called ApplicationName_Development running on SQL Server 2008 R2 Developer edition on my development box.

I added .NET membership tables to the database with no problem. When I tried to get Code First working I received the following error message:

The server encountered an error processing the request. The exception message is "Model compatibility cannot be checked because the database does not contain model metadata. Ensure that IncludeMetadataConvention has been added to the DbModelBuilder conventions.

After some googling, I discovered that I had to delete the database and let EF create the database. That's fine but I lost all my .NET membership tables. I can go back in and add the membership tables again but if my model changes and EF needs to recreate the database then I have to add the membership tables in again.

How do I get around this?


Solution

  • Found a easier workaround here. I hope this helps.

    http://www.paragm.com/ef-v4-1-code-first-and-asp-net-membership-service/