Table Per Hierarchy Inheritance

Discussion of open issues, suggestions and bugs regarding Entity Framework support in ADO.NET Data providers
Post Reply
Dominik
Posts: 29
Joined: Wed 19 May 2010 07:26

Table Per Hierarchy Inheritance

Post by Dominik » Tue 19 Oct 2010 15:04

Hi,

I'm trying to perform a Table Per Hierarchy Inheritance model with Oracle. I follow these steps with SQL Server and I don't have any problem, but there is no way to go with Oracle...

http://www.robbagby.com/entity-framewor ... heritance/

First, my type field in base class used as condition is defined as NUMERIC(1) in database, which is converted automatically to bool in my model. I could change this type to Byte without problems. It accepts 0, 1 and 2 as valid values.

Then, I create a new class that inherits from my base class. In its Entity Mapping Details, I add the base table and I create a new condition, setting my type field equals to 0.

When I validate my model I have the following error:

Error 70 Problem in mapping fragments starting at line 36:Condition member 'Counter.Type' with a condition other than 'IsNull=False' is mapped. Either remove the condition on Counter.Typ or remove it from the mapping.
C:\...\Oracle\Model.edml 1 1

How can this problem be solved? I need to have the same model in both SQL Server and Oracle providers.

Thanks in advance,

Dominik.

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Thu 21 Oct 2010 15:27

The simplest solution is to change the SSDL type of the discriminator column to "int". It worked for me, I can send you a small example if you need it.

Dominik
Posts: 29
Joined: Wed 19 May 2010 07:26

Post by Dominik » Fri 22 Oct 2010 07:22

Thanks, it's working now.

I changed my database type to NUMERIC(2) int order to get this type in my model as Int32 automatically.

Dominik
Posts: 29
Joined: Wed 19 May 2010 07:26

Post by Dominik » Fri 05 Nov 2010 14:51

Hi again,

Our Table Per Hierarchy Inheritance model have an abstract class and three inherited classes depending on a type field.

When we try to use Generics and pass an inherited sub-class to our context in this way:

objectSet.OfType()
.OrderBy(orderByExpression)
.Skip(pageIndex * pageCount)
.Take(pageCount)
.ToList()

We have the following error:

ORA-00942: table or view does not exist
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: Devart.Data.Oracle.OracleException: ORA-00942: table or view does not exist

The same code is working without problems with SQL Server.

Can this problem be solved in any way?

Is it possible to know the result query with dbMonitor tool? If so, how?

Thanks in advance,

Dominik.

Dominik
Posts: 29
Joined: Wed 19 May 2010 07:26

Post by Dominik » Mon 08 Nov 2010 11:06

Hi again,

I was able to get it working adding Oracle ssdl as a embedded recource and sharing csdl and msl schemas generated by SQL Server.

But in any case, I prefer to use full Oracle content schemas.

How can I know what is wrong with my Oracle edml model?

Thanks,

Dominik.

StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Mon 08 Nov 2010 15:08

I will send you a test project in a letter, please check that it was not blocked by your mail filter. Please specify what should be changed in the sample or send us your test project so that we are able to reproduce and investigate the problem.

The table used in the sample is defined as

Code: Select all

CREATE TABLE PEOPLE (
  ID NUMBER(38),
  NAME VARCHAR2(20),
  DISCRIMINATOR_FIELD NUMBER(4) DEFAULT 1 NOT NULL,
  AVERAGE_GRADE NUMBER(38),
  DEGREE VARCHAR2(20),
  CONSTRAINT PK_PEOPLE PRIMARY KEY (ID)
)
Also, please specify the version of dotConnect for Oracle you are using.

Dominik
Posts: 29
Joined: Wed 19 May 2010 07:26

Post by Dominik » Tue 09 Nov 2010 09:56

Hi,

According to your sample project, can I work with DevArt provider using an EDMX data model?

By the moment, I was using DevArt entity model dessigner. As I'm working also with SQL Server databases, could be better to work both database models with ADO.NET Entity Data Model? or is it not relevant?

Thanks,

Dominik.

StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Tue 09 Nov 2010 12:27

You are right, dotConnect for Oracle supports both .edmx and .edml models. You can use the standard Entity Data Model wizard to create .edmx models, the only difference in this comparing to creating models for SQL Server is that you will need to configure another connection string. For more information on using EDM wizard with dotConnect for Oracle, please refer to
http://www.devart.com/dotconnect/oracle ... al_EF.html

As for the different model types, .edml models use Entity Developer instead of the standard Visual Studio editor, and enhanced Devart code generation templates instead of the standard ones. As for the rest, there should be no significant differences in using .edml and .edmx models.

As for the problem with .edml model, could you please send us a complete sample including the exact LINQ to Entities query you are using so that we are able to reproduce the problem?

Also, you can use the dbMonitor application to trace SQL commands sent to the Oracle server in the same way as it is done for common ADO.NET applications. For the detailed information on this, please refer to
http://www.devart.com/dotconnect/oracle ... nitor.html

Dominik
Posts: 29
Joined: Wed 19 May 2010 07:26

Post by Dominik » Tue 09 Nov 2010 12:44

Hi,

Thank you very much for this information about using EDM wizard with dotConnect for Oracle, I will try it as soon as I have some free time.

Respect to my problems with Table Per Hierarchy Inheritance model, I could finally solve it playing a little bit with database types and perform some manually changes at edml schema, but I do not know exactly which of my changes made it work.

Thanks again,

Dominik.

Dominik
Posts: 29
Joined: Wed 19 May 2010 07:26

Post by Dominik » Tue 23 Nov 2010 08:55

Hi again,

I'm trying to perform tracing with DBMonitor tool in this way:

#if TRACING
// Oracle Trace with DBMonitor
Devart.Data.Oracle.OracleMonitor mon = new Devart.Data.Oracle.OracleMonitor() { IsActive = true };
#endif

But instead of include a preprocessor directive, data is always visible at DBMonitor.

Is that normal?

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Thu 25 Nov 2010 17:01

I have sent you a test project. Could you please make some modifications to reproduce the issue and send it back to us?

Post Reply