Master-Details problem

Discussion of open issues, suggestions and bugs regarding Entity Framework support in ADO.NET Data providers
Post Reply
Alladin
Posts: 149
Joined: Mon 27 Nov 2006 16:18
Contact:

Master-Details problem

Post by Alladin » Thu 03 Mar 2011 15:23

Does DevArt EF driver support 0..1 to *..Many relations?

A have two classes IndexDetails and IndexMaster. IndexDetails has a nullable reference to IndexMaster class. IndexMaster class has a collection of IndexDetails instances.

When I add a new IndexMaster, then add a new IndexDetail to the Details collection, all key and reference properties are correctly set.

However, when I do this:
1) Create new IndexMaster A
2) Create new IndexDetails B and add it to the master A
3) Context.SaveChanges <-!!!!!!!!! Oracle exception foreign key not found.

When I do it like this:
1) Create new IndexMaster A
2) Context.SaveChanges (Save master object) - works
3) Create new IndexDetails B and add it to master A
4) Context.SaveChanges (Save child object) - works

Now the question, is EF provider supposed to resolve dependencies and execute inserts in correct order? Or should the developer know in which order he has to save his entities?

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

Post by AndreyR » Thu 03 Mar 2011 16:12

I have sent you a simple sample project illustrating the working scenario with 0..1 - * association.
Could you please make some corrections to reproduce the error?

Alladin
Posts: 149
Joined: Mon 27 Nov 2006 16:18
Contact:

Post by Alladin » Thu 03 Mar 2011 16:35

Thank you.

The problem was that Foreign Key Constraint was missing. Without this information, it's not obvious, that master object must be inserted before the child.

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

Post by AndreyR » Thu 03 Mar 2011 16:51

Glad to hear that the issue is resolved.

Post Reply