TjDillashaw
TjDillashaw

Reputation: 817

Moving a database to another server for MVC C# application

I need to move a database from the local server to another. So I moved all the data through SSMS tool to another database. In the application I have now 2 connection strings and tried to exchange them but do not know how to do it well.

local db connection string:

 connectionString="metadata=res://*/Models.BiuroModel.csdl|res://*/Models.BiuroModel.ssdl|res://*/Models.BiuroModel.msl;provider=System.Data.SqlClient;provider connection string="data source=KOMPUTER\SQLEXPRESS;initial catalog=DefaultConnection;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" 

my second server connection string:

Data Source=db-mssql;Initial Catalog=inzS9776;Persist Security Info=True;User ID=inzS9776;Password=xxxxxxx

My local connection string was auto generated by ADO.NET but when I try exchange these connections string I get some errors like: enter image description here

Upvotes: 0

Views: 801

Answers (1)

Dai
Dai

Reputation: 155708

Entity Framework connection strings wrap a normal SQL Server connection string, just replace the appropriate part, observe:

metadata=res://*/Models.BiuroModel.csdl|res://*/Models.BiuroModel.ssdl|res://*/Models.BiuroModel.msl;
provider=System.Data.SqlClient;
provider connection string=
    "
        data source=KOMPUTER\SQLEXPRESS;
        initial catalog=DefaultConnection;
        integrated security=True;
        MultipleActiveResultSets=True;
        App=EntityFramework
    "

Replace the bit after provider connection string= with the new SQL Server connection string, and don't forget to wrap it in ".

Upvotes: 1

Related Questions