locked
Error using WCF Data Services with EF 4.1 CodeFirst RRS feed

  • Question

  • I did the EF 4.1 with WCF Data Services 2011 CTP walkthrough/tutorial and am getting an error when trying to view the WCF service in my browser. The solution compiled ok with no errors. I have turned on IncludeExceptionDetailInFaults so that I can see the error. Without pasting the whole thing, here is what is likely the relevant text:

    "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."

    As was done in the tutorial, I set it up to create the database with seed data for me on first run. I don't want it on SQLEXPRESS though, so I added a connection string in web.config for the actual SQL Server environment that I want to use. However, when I check it out in SSMS, it appears to have created no new database.

    Anyone seen this error before?

    Thanks,

    Matt

     

    Wednesday, March 23, 2011 12:10 AM

Answers

  • Just in case anyone is interested, I figured out the solution...

    If anyone else gets this error, ensure that the database referred to in the connection string does not exist the first time you run the service. If it's already there, drop/delete it. Then, rebuild the solution in VS and run the service again...it will then work.

    This is something that should be clarified...it's not enough to give EF a completely empty, brand new database to work with...it seems to only be satisfied if it can do 100% of the database creation process, etc. itself.

    -Matt

     

    • Marked as answer by mattstr1221 Wednesday, March 23, 2011 11:11 PM
    Wednesday, March 23, 2011 11:08 PM

All replies

  • Just in case anyone is interested, I figured out the solution...

    If anyone else gets this error, ensure that the database referred to in the connection string does not exist the first time you run the service. If it's already there, drop/delete it. Then, rebuild the solution in VS and run the service again...it will then work.

    This is something that should be clarified...it's not enough to give EF a completely empty, brand new database to work with...it seems to only be satisfied if it can do 100% of the database creation process, etc. itself.

    -Matt

     

    • Marked as answer by mattstr1221 Wednesday, March 23, 2011 11:11 PM
    Wednesday, March 23, 2011 11:08 PM
  • Happy to see that, Matt!

    And Thank you for sharing your solution to us! That must be very useful!

     

    Have a nice day,


    Jackie Sun [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, March 24, 2011 1:55 AM
  • It's great! Thank you for your sharing!
    Wednesday, June 8, 2011 5:26 AM
  • Plus, be sure to disconnect from the database in VS
    Sunday, September 18, 2011 1:15 PM
  • Good find Matt it helped me - I was a little puzzled when I first saw the error. 

    I wonder if there is a way to regenerate the Entity Framework EdmMetadata table without a complete database build.

     

    Mark

    Wednesday, December 14, 2011 5:38 PM
  • Hello MS,

    I dropped the database and of course I get a "CREATE DATABASE permission denied in database 'master'". A DB-Admin on a shared server will never give me such rights. How can you possibly design something that only works properly with high privileged rights (i.e. CREATE/DROP DATABASE) ? Very bad security practice.

    Monday, February 20, 2012 3:48 PM