so developed application, in use. application has database references. asked make changes, made copy of database own usage. dbcontext
-deriving class looks kinda this:
public class applicationdbcontext : dbcontext { //dbsets... #if debug public applicationdbcontext() : base("debugconnection") { } #else public applicationdbcontext() : base("defaultconnection"){ } #endif }
that way, when make changes can run add-migration
, update-database
, hit debug copy of database. when i'm ready deploy, switch release mode , run update-database
. here's problem comes in: division wants use same app. made new database, how can migrations hit database?
i tried making new configuration, web.config transform file match. however, seem entity framework doesn't take transform files account when checking them update-database
; uses regular one. tried making blank file includes #define environment_release2
, changing above
public class applicationdbcontext : dbcontext { //dbsets... #if debug public applicationdbcontext() : base("debugconnection") { } #else #if environment_release2 public applicationdbcontext() : base("release2connection"){ } #else public applicationdbcontext() : base("defaultconnection"){ } #endif #endif }
the idea being 1 .pubxml specify ignoring file , other wouldn't. however, seems if #define
in file, it's not read.
so ultimately, what's right way manage 3 (or more) databases entity framework?
Comments
Post a Comment