Database Switching in LinqToSql

How can we change the underlying database for Linq-based WebApp?

, eg:

When we release our web application, say for release from production, if you use ADO.NET, it is as simple as changing the connection string in web.config to indicate the database you are using. Databases are almost identical, other stored data.

What and how to change UnerLying Database when using LINQ?

Note; Using C #

thank

+3
source share
3 answers

. , :

public static class DCHelper
{
  public static MyDataContext Create()
  {
     return new MyDataContext(ConfigurationManager.ConnectionStrings["CS"].ConnectionString);
  }
}

, , , . create .

+1

; DataContext ( SqlMetal) , . ConfigurationManager ( - ) .

, DBML , ConfigurationManager ; , IDE , . ( ).

+4

, Web.Config, .

... , ( ). /. LINQ 2 SQL MSSQL ( , .)

LINQ to Entities, .

-1

Source: https://habr.com/ru/post/1729595/


All Articles