0

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

1 Answer 1

1

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 ".

Sign up to request clarification or add additional context in comments.

2 Comments

Ok it works! But could you tell me why when I create a new user is added to the local database and not to the database on an external server? Both databases have the same tables. On the other hand, when I create any data other than creating a new user, they are added correctly to the external database.
@JustBeginner Your application was connected to the old server for some reason. That generally shouldn't happen. We would need to know more about your application before saying anything, but I don't think it will happen again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.