How do I allow the EF4 CodeFirst database initializer to run under development, but not run in production

后端 未结 5 654
有刺的猬
有刺的猬 2021-01-01 07:06

I am attempting to deploy my first alpha version of a system online for a few people to start using. On development I make heavy use of the DropCreateDatabaseOnModelC

5条回答
  •  耶瑟儿~
    2021-01-01 07:21

    You can always create a new Configuration (in addition to Debug and Release). You would then define a Conditional Compilation Symbol for the new configuration. For example if I created a new configuration called LocalDebug (with the same settings at the default debug) I would then add LOCALDEBUG to the Conditional Compilation Symbols. With this defined you can use:

    #if LOCALDEBUG
      //do database stuff
    #endif
    

    Then you can still deploy the built in debug configuration and this section will not fire.

提交回复
热议问题