Deploy Entity Framework Code First

后端 未结 2 466
无人及你
无人及你 2021-02-05 14:07

I guess I should have thought of this before I started my project but I have successfully built and tested a mini application using the code-first approach and I am ready to dep

相关标签:
2条回答
  • 2021-02-05 14:17

    Actually database initializer is only for development. Deploying such code to production is the best way to get some troubles. Code-first currently doesn't have any approach for database evolution so you must manually build change scripts to your database after new version. The easiest approach is using Database tools in VS Studio 2010 Premium and Ultimate. If you will have a database with the old schema and a database with the new schema and VS will prepare change script for you.

    0 讨论(0)
  • 2021-02-05 14:20

    Here are the steps I follow.

    1. Comment out any Initialization strategy I'm using.
    2. Generate the database scripts for schema + data for all the tables EXCEPT the EdmMetadata table and run them on the web server. (Of course, if it's a production server, BE CAREFUL about this step. In my case, during development, the data in production and development are identical.)
    3. Commit my solution to subversion which then triggers TeamCity to build, test, and deploy to the web server (of course, you will have your own method for this step, but somehow deploy the website to the web server).
    4. You're all done!

    The Initializer and the EdmMetadata tables are needed for development only.

    0 讨论(0)
提交回复
热议问题