How to prevent DbContext from altering the database?

后端 未结 3 1447
广开言路
广开言路 2020-12-14 21:28

I\'m learning Entity Framework (currently using EF6 beta) and I\'m using the code first pattern on an existing database. The entities and DbContext class are cr

3条回答
  •  渐次进展
    2020-12-14 22:17

    Set the initialiser for your context to null.

    That should leave the database in it's existing state when the application starts up.

    Note that you'll get an exception if you try to run the application after altering your dbContext class and/or your database schema, as your database schema will no longer match what the context expects.

提交回复
热议问题