Entity Framework is trying to create a database, but its not what I want

前端 未结 2 420
无人及你
无人及你 2021-02-08 19:08

I have a small asp.net mvc4 application (working fine in my local machine), that uses entity framework v4.1.0.0 with ADO.net DbContext Generator.(SQL Server 2008 r2)

I a

2条回答
  •  野性不改
    2021-02-08 19:24

    put this code into the Application_Start() method of Global.asax or constructor on your DbContext class

    Database.SetInitializer(null);
    

    If you want to recreate database when POCO domains are changed, use following code instead of above

    Database.SetInitializer(new DropCreateDatabaseIfModelChanges());
    

提交回复
热议问题