开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜