Place to put Database.SetInitializer

前端 未结 5 1421
萌比男神i
萌比男神i 2020-11-30 07:10

I\'m working on a project that at can end up with multiple UI versions / variants, but so far I\'ve got two subprojects in my solution Web - containing Web interface with A

5条回答
  •  有刺的猬
    2020-11-30 08:09

    You would need a mechanism to call the Database.SetInitializer method before the very first usage of the DbContext. That is why its usually called in the Global.asax file.

    You can create a class with an initialization method in your tm.Service project and call it in the Application_Start method and put the Database.SetInitializer in that initialization method.

    Its OK to supply the connection string from a setting file.

提交回复
热议问题