Code First - How to deploy app to existing database RRS feed

  • Question

  • I need to deploy a new EF 4.1 Code First app to an empty database. I do not have rights to create the database, so Code First can't do that either. I can create tables but not the database. What's the best approach to deploy my app?

    My Code First app runs fine on my local database, where Code First has created the tables.

    I tried scripting out the tables from my local database, and recreating them on the production database, but SQL Server Management Studio gives errors, such as "Foreign key 'Keyword_Questions_Source' references invalid table 'dbo.Keywords'."

    Then I tried running my app with it pointed in the web.config to the production database, thinking Code First would just create the tables it needs, but SaveChanges() throws errors like "Invalid object name 'dbo.Keywords'"

    Wednesday, July 27, 2011 7:40 PM