LINQ to SQL and DBML file - development of several databases

The way I develop may be wrong, any advice is welcome.

I currently have a WPF application that uses the SQL2008 database. I have a copy of the database on a laptop and on my home machine. My application is versioned using SVN, and I can obviously go from my work laptop to my home computer and update / commit as required to make sure that I use the latest code for the application.

However, there is another story in the database in which any change that I make, I back up and then transfer the backup to another machine, etc. Thus, I get data and changes made to each system. To do this, connect to the database using a different connection string, and I change the setting in my application to use a different connection based on my location.

Now I started using LINQ to SQL and DBML files in my application and finally came to the question, I don’t know how I can change the connection string that it uses in the code, so it will use the correct database in DBML.

Also, is there a better way to migrate the database, so I don’t need to backup and restore? The only reason I did not implement the version of the scheme is because I am not sure how this will process my data, since this is the key to my development, that is, various environment settings, etc. Stored in the database and executed at run time.

+3
source share
5 answers

Your expression: Now I started using LINQ to SQL and DBML files in my application, and finally, after asking a question, I don’t know how I can change the connection string that it uses in the code, so it will use the correct database in DBML .

Yes it is possible.

MYDataContext mycontext = new MYDataContext ( " " );

, ConnectionString.

+1

, . , ?

  • SVN .
  • , . , db, . , , .bak. SVN, . DB , SVN . , db . , SVN ( Tortise Windows) , . .

  • - ASP.NET, web.config, connectionstrings.config .., : , , , (), ConfigurationSettings, , , , . :

, DEV1. SERVER1. , DEV1.connections.sqlserver SERVER1.connections.sqlserver. GetConfig ( "connections.sqlserver" ). GetConfig , .

, .configs , . , , . , - , , - .

LINQ - linq dbml . , . :

, 2 : 1 - - 2 -

dbml . App.config , , LINQ . connectionstrings.confing -, , LINQ , .

+1

Sql Server Merge Replication SQL Compact 3.5 / . Sql Server Standard Edition.

- Microsoft Sync Framework.. ..

http://msdn.microsoft.com/en-us/sync/default.aspx

0

red_gate SQL COmpare SQLDataCompare script . , , , prod. , SVN, script .

0

, dbml , . .

I really don't have a good solution to migrate the databases and continue using the backup and restore method.

0
source

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


All Articles