Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the schema via connection string when connecting to Oracle using Entity Framework?

When I generated the EDMX file it set the Schema for each EntitySet

<EntitySet 
    Name="TableName"
    EntityType="Model.Store.TableName"
    store:Type="Tables"
    Schema="MySchema" />

The problem is that if I want to switch to the production database I have to change the EDMX since I don't know how to choose the Schema in the connection string.

How to do it?

like image 606
Jader Dias Avatar asked Mar 27 '12 17:03

Jader Dias


People also ask

How do I change the connection string in SQL Developer?

Under the Details tab select Connect Identifier. Put the connection string into the text box next to Connect Identifier. Click Test if you'd like, to make sure it works. Click Save.


2 Answers

I just had to edit the EDMX and remove the Schema from every EntitySet

<EntitySet 
    Name="TableName"
    EntityType="Model.Store.TableName"
    store:Type="Tables" />

Now it connects to the default schema for a given user.

like image 99
Jader Dias Avatar answered Oct 20 '22 00:10

Jader Dias


If the code first method is an option you can override the OnModelCreating method in your DbContext class. In the OnModelCreating method you can put logic in to detect oracle and rename the schema accordingly. The code first approach has been asked about here.

like image 45
j-u-s-t-i-n Avatar answered Oct 20 '22 00:10

j-u-s-t-i-n