Note that there are some explanatory texts on larger screens.

plurals
  1. POASP.NET MVC and multiple environments
    primarykey
    data
    text
    <p>How does ASP.NET MVC, if at all, deal with or provide ways to create your application using multiple environments? For example:</p> <ol> <li>Development environment (local machine, probably run via the built-in web server and talking to a local database)</li> <li>Testing (runs against a preloaded databse with example data, although this part could be skipped and mocks could be used)</li> <li>Production database on a real server with real data</li> </ol> <p>Ruby on Rails has the concept of environments and "automagically" can deduce if you're in development or production, so you can specify your connection information (connection string) in a config file and the framework dynamically pulls the appropriate one. Is there a similar way of doing things with .NET MVC? If not then how are professional developers using .NET MVC handling different environments? </p> <p>The only way I can think of is to manually add an "environment" global method (or use an enum, or something like that, maybe this is a use for something like the State pattern?) and store the different connection strings in the web.config file, and then create a base class which all data access classes derive from which provides a way to obtain the connection string for the current environment; this would then have to be set to production when the time comes to put the application live. </p> <p>Is there another way? Most of the .NET MVC videos and articles I've seen don't even bother with separate environments but only use a development database and don't indicate how you do it in production.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload