Search code examples
entity-frameworkentityentity-framework-ctp5

Entity Framework 4 CTP 5 Code First Development


I am trying to do some tests using EF4 + CTP5 with code first development by writing POCO classes and have faced the following problems

  1. Connecting to existing database throws me the exception:
    Model compatibility cannot be checked because the database does not contain model metadata

  2. While I can create a new database from code by giving a new file name in a connection string, not able to open the file (database) using the Management Studio after running few tests against, the Management studio doesn't allow to add the file when trying to attach the database with no specific error detail provided.


Solution

  • For #1, did you try adding the following to your global.asax?

    Database.SetInitializer<CustomContextNameHere>(null);
    

    where "CustomContextNameHere" is your context object.

    As far as #2 goes, I am assuming you mean the default ASPNETDB.MDF file. Have you tried opening the file with the Server Explorer in VS? It may open right up if you double-click on it in the solution.