score:0

Well, you never actually associate the new act with any gig - is that what is missing?

dbGig.Acts.Add(dbAct);

or maybe:

dbAct.Gig = dbGig;

or something with the ids.

i.e. are you sure the act in the db is for the gig?

score:2

Try opening a fresh DBContext at the beginning of this block. If you're using the same context for the first and second run, it won't see the inserted record the second time around. Resetting the context should force it to see the latest rows in the table.

score:1

An alternative to gfrizzle's answer is unless you have a compelling reason to do so don't call SubmitChanges until after you have done all the DB work.

score:0

I had a similar issue, the problem / solution in my case was that the internal class that represented the database table was missing part of the primary key.

This appeared to work ok until the data from the DB caused a primary key constraint in the code that the database was happy with.

PT


Related Articles