开发者

Why is EF4.1 CodeFirst is creating a database even without a `Database.SetInitializer<>()` call?

开发者 https://www.devze.com 2023-02-20 02:03 出处:网络
I have commented out all calls to Database.SetInitializer<>() in my EF Code First application.However, even without any explicit calls to create the database, my Asp.net MVC application is still

I have commented out all calls to Database.SetInitializer<>() in my EF Code First application. However, even without any explicit calls to create the database, my Asp.net MVC application is still creating a database. I have several reasons why this is an issue:

1) I don't like the fact that EF is creating a new database without me telling it to.

2) It keeps trying to create (or 开发者_JS百科update) the database on my webhost (even though the database already exists), and thus I am getting permission denied exceptions.

Does anyone have any insight why this seems totally out of my control?


In CTP 5 the solution was

Database.SetInitializer<MyContext>(null);

I think this didn't change in EF 4.1. If you comment the call out it defaults to DropCreateDatabaseIfModelChanges.

0

精彩评论

暂无评论...
验证码 换一张
取 消