Reputation: 45
I am using entity framework model first approach in WCF
.
The EF creates a connection stringwhich looks something like this:
automatically for the first time.
Now I want to change the connection string as database is located in other server.
How can I do it?
Connection string looks like this for now:
<connectionStrings><add name="Entities" connectionString="metadata=res://*/Database.Model1.csdl|res://*/Database.Model1.ssdl|res://*/Database.Model1.msl;provider=Oracle.ManagedDataAccess.Client;provider connection string="data source=AB;password=admin;persist security info=True;user id=TEST"" providerName="System.Data.EntityClient" /></connectionStrings>)
Regards Anudeep
Upvotes: -1
Views: 1787
Reputation: 1502
Remove the connection string from the app.config file, re-run the entity Data Model wizard by right-clicking the designer and chose Update Model From Database, it will guide you to build a new connection. Or else directly edit the Datasource and credentials in the existing connection string in App.config.
Upvotes: 2
Reputation: 5858
One simple way is to modify the app.config or web.config file with the new connection details so calling the var context = new DataContext("NewServerEntities") constructor will use the named connection in your config file.
<add name="NewServerEntities" connectionString="metadata=res://*/Database.Model1.csdl|res://*/Database.Model1.ssdl|res://*/Database.Model1.msl;provider=Oracle.ManagedDataAccess.Client;provider connection string="data source=NewServer;password=admin;persist security info=True;user id=TEST"" providerName="System.Data.EntityClient" />
Upvotes: 2