Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Entity framework connection string

I'm not sure what to regarding the following problem so any help would be appreciated. I'm working on an application that is connected to the online MSSQL database and everything is working fine. The model I'm using is entity model.

The problem is that I have to change the connection string from the online database to the local one, but I don't know how. Creating new model isn't an option. I tried changing the connection string in web.config, but errors are the only thing I get...

This is what I have in web.config:

<connectionStrings>
<add name="PravosudnaAkademijaEntities" connectionString="metadata=res://*/PrakModel.csdl|res://*/PrakModel.ssdl|res://*/PrakModel.msl;provider=System.Data.SqlClient;provider connection string='Data Source=MY-PC;Initial Catalog=pak_baza;Integrated Security=True" providerName="System.Data.EntityClient" />

like image 797
wegelagerer Avatar asked Mar 03 '11 03:03

wegelagerer


2 Answers

"Data Source=HRVOJE-PC;Initial Catalog=pak_baza;Integrated Security=True"

This is the part you should be changing, it's just your regular SQL server connection string, HRVOJE-PC is the machine name or IP, pak the name of your database. If you have a DB on your local machine you want to replace HRVOJE-PC with localhost.

For examples of SQL Server connection strings check here

like image 144
BrokenGlass Avatar answered Sep 27 '22 18:09

BrokenGlass


Alternatively, there is a DataContext constructor that takes a connection string parameter that you could use if it's a temporary change and are planning to switch back to the one that you used to use.

like image 22
Bala R Avatar answered Sep 27 '22 19:09

Bala R