Fetch Oracle foreign keys


I have a problem reading an Oracle schema, in particular the database schema reader doesn't fill foreign keys on DatabaseTable object but set correctly IsForeign property on DatabaseColumn object.

I've attached a sample script to create two tables AA and BB where BB has a foreign key to AA.

I expect to read for each DatabaseTable the DatabaseTable.ForeignKeys.

In my example DatabaseTable 'BB' should have a ForeignKey in DatabasetTable.ForeignKeys which refer 'AA'.

I have tried to read the list of tables with the method DatabaseReader.AllTables() and DatabaseReader.ReadAll().

I have tried the same example on SQL Server and it run, in Oracle I didn't have the same luck.

Any advice? Can someone help me?



file attachments

Closed Nov 21, 2015 at 3:16 PM by Martinjw
No more information


Martinjw wrote Mar 12, 2015 at 6:49 AM

I tried on Oracle 11 and 12, using System.Data.OracleClient, Oracle.DataAccess.Client and Devart (all latest versions). On my machines, this works...
            var dbReader = new DatabaseReader(connectionString, "System.Data.OracleClient");
            dbReader.Owner = "XX";
            var schema = dbReader.ReadAll();
            var bb = schema.FindTableByName("BB");
            var fk = bb.ForeignKeys.Single();
            Console.WriteLine(fk.RefersToTable); //"AA"
            Console.WriteLine(fk.Columns.Single()); //"AA_ID"
            Console.WriteLine(fk.ReferencedTable(schema).Name); //"AA"
            Console.WriteLine(bb.FindColumn("AA_ID").IsForeignKey); //true
Are you using a different ADO provider/version?