MVC “Add Controller” is “Unable to Retrieve Metadata…Config System Failed to Initialize”

前端 未结 11 1122
天涯浪人
天涯浪人 2021-01-04 18:31

From scratch, I made a new solution with two projects: one was MVC 3 and the other a supporting EF 4.2 project. The whole thing builds successfully. From the MVC project I

11条回答
  •  南方客
    南方客 (楼主)
    2021-01-04 18:53

    I added this to my Global.Asax file so that a) the database was started immediately and b) the table definition was added. allowing the Controller to find the table definition:

     System.Data.Entity.Database.SetInitializer(new CreateDatabaseIfNotExists());
    

提交回复
热议问题