In Entity Framework, how to generate entities from different Oracle schemas in VS2017

c# entity-framework entity-framework-6 odp.net-managed oracle

Question

I am currently attempting to generate code from tables from an existing Oracle 12 database from within Entity Framework 6. The problem I am having is that while it is able to see the schema that I own when I log into the environment, Entity Framework can't seem to see any other schemas that I have access to.

How can I change it so that I can see another schema?

I have used Entity Framework model-first and code-first. I can go in an manually change the schema on a generated table that I own in Oracle and it will work, but that would mean generating my own versions of tables from the other schema in my own schema just to be able to use them via Entity Framework.

Generating all the code from all the existing tables would be a cumbersome job otherwise.

How do I solve this problem?

1
0
1/17/2018 6:41:20 AM

Accepted Answer

Ok, I have solved the problem. There is a particular way to get schemas working with Oracle in Entity Framework, and you can get full use of Entity Framework, including the Designer/Canvas if you want.

First, in your application, using Nuget, install the Oracle.ManagedDataAccess.EntityFramework package. If you look at the Description of this package in Nuget, it says it depends on EntityFramework and Oracle.ManagedDataAccess. So install the one package and it will install all that, if its missing.

Next, if you read the comment at the bottom of that description, it says "Note: The 32-bit Oracle Developer Tools for Visual Studio download from http://otn.oracle.com/dotnet is required for Entity Framework design-time features and for other Visual Studio designers such as the TableAdapter Wizard. This NuGet download does not enable design-time tools, only run-time support."

So you need to install the Oracle Tools for Visual Studio that matches your environment. Installing ODTwithODAC packages won't give you the right outcome.

Finally, add a connection to the Oracle database. Then, open the Server explorer and find that connection. Right-click on the connection, and select Filters. Then select Displayed Schemas. Edit the value, adding in all the schemas you want to display, by clicking on the "..." button and selecting the schemas. Then click Update. Then click Ok.

Next time you want to select an object from a schema that you just added, it will appear in the Entity Framework list.

1
1/18/2018 9:15:12 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow