Sunday, July 3, 2016

Adding objects from different schemas using Entity Framework with Oracle

At first, it looked like there was is no Entity Framework support to adding objects (say, tables) created in schemas other than the one used in the database connection.

But turned out it is possible. Stackoverflow will list some "workarounds" , but there is no need to - because SO lists one post that gives the exact solution for this problem, and it looks great.

Summarizing it:

You can either add more schemas under which search for objects to add during the creation of the Ado.net object (while adding the connection) - or by modifying the existing connection in the Server Explorer in Visual Studio.



If you are adding the ADO.NET object, you need the connection definition window above - and if you already have your ADO.NET object there, go to Visual Studio -> View -> Server Explorer, search for the desired connection under Data Connections and right click it. Then choose Modify. You will get the window above.

The steps to follow are:
  1. Select the Filter tab
  2. Click the 3 dots singled out, and add the schemas you want to be included by EF when searching for objects to add to the model.
  3. After you are done with step 1, click the Update button singled out in the screenshot.
That's it. You can right click your edmx file, click Update Model From Database, and you will now have, under Tables, the tables listed by their schema.

1 comment: