Parent - Child insert with .Net Entity Framework

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
intiwilly
Posts: 3
Joined: Fri 08 Jan 2010 08:37

Parent - Child insert with .Net Entity Framework

Post by intiwilly » Fri 08 Jan 2010 08:56

Hi,

I'm using dotConnect Oracle 5.35.62 trial version. I want to ask how to insert parent child association in one transaction.
Maybe similiar like this in SQL Server version http://social.msdn.microsoft.com/forums ... bc480ee8a/

I've tried this following code :

Code: Select all

            Master ap = new Master();
            Detail ad = new Detail();
            ap.Name = "Test Data";
            ad.Visited = "US";

            ap.Detail.Add(ad);

            db.AddToMaster(ap);
            db.SaveChanges();
The record successfully insert to both table in database but the reference id (MasterId Column) in Detail table always refer to 0.

I've use trigger and sequence to produce auto increment number both in Master table and Detail table and it work fine if i do this with sql insert query.

Is there any idea how to do this with valid reference id?

Thanks,

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

Post by AndreyR » Tue 12 Jan 2010 10:00

I have just tried the same code and succeeded. Please make sure that you have set the StoreGeneratedPattern attribute
for the autoincremented columns to Identity, this may be the reason.
We don't have an opportunity to set this attribute automatically in Oracle.

intiwilly
Posts: 3
Joined: Fri 08 Jan 2010 08:37

Post by intiwilly » Thu 21 Jan 2010 09:24

AndreyR wrote:I have just tried the same code and succeeded. Please make sure that you have set the StoreGeneratedPattern attribute
for the autoincremented columns to Identity, this may be the reason.
We don't have an opportunity to set this attribute automatically in Oracle.
thanks, it works well after i set the StoreGeneratedPattern attribute

http://msdn.microsoft.com/en-us/library/bb738536.aspx

Post Reply