asp.net mvc - How to switch between test and production databases with Entity Framework 5 -
I have separate testing and production databases for my ASP.NET MVC 4 app. How can the ANTI framework switch between programming between these two databases, using unit framework 5? This application knows what time database should be used, so I need an application to be able to change the Entity Framework so that it can use the right database at the right time.
Does anyone know how to accomplish this and / or a good example is available?
EDIT: Because of my app's arrangement, I need to answer GVM's answer. The last remaining thing is that I do not know how to send logic to the base class. Here's what I mean:
  Public category YourContext: DbContext {public YourContext (): Base ("yourNameOrConnectionString") {}}    The problem is The code does not work:  
  string dbConnectionString = "MyDBTest";    How to send an argument to a base class, in this case your contact (): to use base (var db = new YourContext (dbConnectionString)) {// db Code} ()   
 
  Use configuration conversions. This is what is there for you. Of course, though, the configured conversion is a little confusing because the debugger does not really use them, expand me, expand me.  
 By default, you have three web The configurations are obtained:  Web.config ,  Web.Debug.config  and  Web Release.config . The latter two are integrated with Solution Explorer, but you can expand  Web.config  to see them.  Web.Debug.config  and  Web.Release.config  are conversions. They use special XML-style syntax so that you have permission to change settings in  change , main  Web.config  file. Each corresponds to a "configuration", that is, "debug" and "release", which are originally created in Visual Studio. You can add additional configurations as you need them.   Now, here, despite the name of things being confused,  debug  is not really used in the configuration, while debugging, a better name might possibly be  development  or  scaffolding ; This is the configuration, when you deploy the test capability on the site instead of production. If the  release  is for config production, what you want in your main  Web.config , specify the connection string for your local development database. Then, in  debug  and  release  configs, you add a change to convert to the / staging / output database connection string respectively. When you want to debug locally, a main  web.config  will be used, and then when you publish your application, you can either  debug  or  Releases , depending on the environment in which you deploy, and  then  the conversion will have to be properly changed to  web.config .   For more information about the changes and how to write them, see:   
 
Comments
Post a Comment