ENTITY FRAMEWORK – ORACLE CONNECTION STRING

I see many hits to my post related to Entity Framework and Oracle related articles. I thought I will share some information which I figured out after fighting for sometime.

Depending on how you manage your TNS names, your connection string in web.config and app.config may not work sometime. The best way to mitigate that risk to have your connection string as follows. I am assuming that you have downloaded the EF provider from Oracle’s web site and installed it.

<add name=”MyEntities” connectionString=”metadata=res://*/OracleModel.csdl|res://*/OracleModel.ssdl|res://*/OracleModel.msl;provider=Oracle.DataAccess.Client;provider connection string=&quot;DATA SOURCE= (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = MY-SERVERNAME-OR-IP)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = PRODUCTION) ) );PASSWORD=MySecret*1;PERSIST SECURITY INFO=True;USER ID=JAMES.BOND&quot;” providerName=”System.Data.EntityClient” />

 

Oracle provider assemblies are added to GAC. So, it is important to install this on every machine from where you want to access Oracle database using Entity Framework.

Tagged , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: