Mapping Oracle user-type column and entity-side relation

Discussion of open issues, suggestions and bugs regarding Entity Developer - ORM modeling and code generation tool
Post Reply
keeper
Posts: 17
Joined: Mon 27 Dec 2010 09:20

Mapping Oracle user-type column and entity-side relation

Post by keeper » Tue 28 Dec 2010 16:20

Is there a way to map an Oracle user-type column?

-- EDIT --
Also is there a way to create entity association from the designer? I'm trying to create a one-to-many relation using a primary key for the "one" side and a non-primary column on the "many" size (a normal relation between master-detail tables).

Thanks

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

Post by AndreyR » Wed 29 Dec 2010 11:23

There is no support for Oracle Object types neither in Entity Framework, nor in LinqConnect.
Could you please specify the approach you are using to create association?
Is there a corresponding foreign key in database (in this case the association should be generated automatically during Database First model creating)? In this case we will need the script of the database objects to reproduce the issue.
If you are using the Model First approach, you can simply right-click the model surface (or any entity) and select the "Add Association" option.
If you encounter any errors in this scenario, please provide us with the error message and some steps for reproducing the problem.

keeper
Posts: 17
Joined: Mon 27 Dec 2010 09:20

Post by keeper » Wed 29 Dec 2010 14:05

I'll try to explain my situation:
I have two tables without any foreign key and I can't change the DB.

Code: Select all

Table MASTER(ID,...)
Table DETAIL(ID,IDMASTER,...)
I'd like to create an association between them like

Code: Select all

DETAIL.IDMASTER=MASTER.ID
so I can use

Code: Select all

Master.Details -> all related Detail entities
Detail.Master -> the related Master entity
Is it possible to create this relation/association using Entity Developer?

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

Post by AndreyR » Wed 29 Dec 2010 16:26

Yes, it is possible.
Add the association as I have described here:
you can simply right-click the model surface (or any entity) and select the "Add Association" option.

keeper
Posts: 17
Joined: Mon 27 Dec 2010 09:20

Post by keeper » Thu 30 Dec 2010 08:00

I tried and it gave me an error.
These are my tables:

Code: Select all

AprocManChiamate(Id, ...) PK=Id
AprocManAttivita(Id, IdChiamata, ...) PK=Id
The relation I want to create is Attivita.IdChiamata = Chiamata.Id
My exact steps are:
  • Right click an entity and select "Add association" (I chose the entity that is on the "one" side)
  • Change the Child Class to the "many" entity
  • Add Referential Constraint Properties for the two tables (Id IdChiamata)
  • Click OK
The relation is created but the connecting line is red and the error is (translated by Google from Italian)
Error 2 The referenced Dependent Role AprocManAttivitas must be a subset of key EntityType DataModel.AprocManAttivita referenced in the referential constraint for Dependent Role Relationship DataModel.AprocManChiamate_AprocManAttivita.
I think the designer want the column (IdChiamata) to be part of the entity key (which I think is not needed to create the relation).
What can I do?

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

Post by AndreyR » Thu 30 Dec 2010 15:43

I am unable to reproduce the error.
Here are the steps I was performing:
1. Right-click the model->Add Association.
2. Set the Master class as Parent Class, set 0..1 multiplicity for this association end
3. Set the Detail table as Child Class, set * multiplicity for this association end.
4. Click OK. Designer creates an unnecessary Id1 field in the Detail entity (a foreign key column). I delete this column in designer.
5. I edit the created association setting the Master and Detail properties.
I have sent a model to the e-mail address provided in your forum profile.

keeper
Posts: 17
Joined: Mon 27 Dec 2010 09:20

Post by keeper » Mon 03 Jan 2011 09:32

I opened your sample model and there isn't any error in the relation but I see many parsing error (about attributes and namespaces).
I'm using the latest dotConnect for Oracle (trial, 6.00.70) and my version of Entity Developer is 3.0.60
May be this is the problem? Comparing our files the only difference I see are the "xmlns" attributes.
I created the same exact model as the one you sent me and I still get the previous error.
I replied your e-mail with my model attached.

keeper
Posts: 17
Joined: Mon 27 Dec 2010 09:20

Post by keeper » Mon 03 Jan 2011 14:12

After a couple of test I recreated the exact steps that create my error:
These are the table scripts I use (Oracle 10.2.0.3.0):

Code: Select all

CREATE TABLE TEST
(
  ID     NUMBER,
  FIELD  VARCHAR2(10 BYTE)
)
LOGGING 
NOCOMPRESS 
NOCACHE
NOPARALLEL
MONITORING;


CREATE TABLE TEST_DETAIL
(
  ID         NUMBER,
  PARENT_ID  NUMBER,
  FIELD      VARCHAR2(10 BYTE)
)
LOGGING 
NOCOMPRESS 
NOCACHE
NOPARALLEL
MONITORING;


CREATE UNIQUE INDEX TEST_PK ON TEST
(ID)
LOGGING
NOPARALLEL;


CREATE UNIQUE INDEX TEST_DETAIL_PK ON TEST_DETAIL
(ID)
LOGGING
NOPARALLEL;


ALTER TABLE TEST ADD (
  CONSTRAINT TEST_PK
 PRIMARY KEY
 (ID));

ALTER TABLE TEST_DETAIL ADD (
  CONSTRAINT TEST_DETAIL_PK
 PRIMARY KEY
 (ID));
After I add a "Devart Entity Model", connect to the database and create an empty model.
I add the two tables by dragging them from my "Database Explorer".
Then I try to add an association using these settings:
http://freeebayimagehost.com/images/ybu ... lfclgm.png
After clicking "OK" my association is in red and I get the error I posted some days ago (translated by Google):
The properties referenced Dependent Role TestDetails must be a subset of key EntityType INTRATESTModel.TestDetail referenced in the referential constraint for Dependent Role Relationship INTRATESTModel.Test_TestDetail.
What's going on?

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

Post by StanislavK » Tue 04 Jan 2011 15:10

Could you please send us the model with which this issue can be reproduced?

I've created a model for the tables you've specified, and created an association as described on the scrennshot. The association was created successfully, and no errors were found in the model. I will send you this model in a letter, please check that it was not blocked by your mail filter.

keeper
Posts: 17
Joined: Mon 27 Dec 2010 09:20

Post by keeper » Tue 04 Jan 2011 15:38

I sent the model through the contact form.
Your model when opened by Entity Developer shows error about some namespaces:

Code: Select all

(error) http://schemas.microsoft.com/ado/2009/02/edm/ssdl
(expected) http://schemas.microsoft.com/ado/2006/04/edm/ssdl
and

Code: Select all

(error) http://schemas.microsoft.com/ado/2008/09/edm
(expected) http://schemas.microsoft.com/ado/2006/04/edm OR http://schemas.microsoft.com/ado/2007/05/edm
May be I'm missing some patch/service pack?

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

Post by StanislavK » Wed 05 Jan 2011 15:31

The difference is that the model I've sent is generated for Entity Framework 4.0, whereas yours one was generated for EF 1.0. You can change the framework that should be used in the model properties (e.g., select 'Edit Model Properties' from the pop-up menu).

To set the association under EF 1.0, you can perform the following:
- in the model properties, select the Synchronization -> Mapping node;
- enable the 'Enable automatic synchronization ...' check box;
- add the association with the 'Add association' item of the pop-up menu;
- remove the ParentId property from the TestDetail entity.

keeper
Posts: 17
Joined: Mon 27 Dec 2010 09:20

Post by keeper » Mon 10 Jan 2011 09:52

That was the problem!
Thanks again for your support!

Post Reply