EF 4 and EntityObject's ID not updating after insert
Posted: Wed 05 May 2010 14:11
Hello all,
I have a problem with forcing Entity Framework 4 to update sequenced ID in EntityObject after inserting.
I'm using following components:
- dotConnect for Oracle 5.60 Professional Trial,
- Visual Studio 2010 with Entity Framework 4,
- Oracle 11gR1 database.
Tables in database have their corresponding sequences and BeforeInsert triggers defined.
ID columns in EF model all have attribute StoreGeneratedPattern set to Identity.
I'm doing the following:
1. create specific EntityObject using CreateObject method of ObjectContext,
2. I'm leaving ID field unset (it's value is 0 by default),
3. I'm adding EntityObject to EntitySet,
4. and call SaveChanges.
Record is created in database with valid sequenced ID value (for example: 12).
[b]EntityObject's ID is still set to 0.[/b]
Question:
What can be done to force EF to refresh ID value after calling SaveChanges?
Thank you in advance.
PS. I went through the forum and found that I'm doing it right but it seems to be not working for me. Maybe I'm missing something?
PS.2. I have investigated SQL statement logged by dbMonitor and there were only insert statements. I would guess there should be some select added to insert statement for retreiving new ID.
I have a problem with forcing Entity Framework 4 to update sequenced ID in EntityObject after inserting.
I'm using following components:
- dotConnect for Oracle 5.60 Professional Trial,
- Visual Studio 2010 with Entity Framework 4,
- Oracle 11gR1 database.
Tables in database have their corresponding sequences and BeforeInsert triggers defined.
ID columns in EF model all have attribute StoreGeneratedPattern set to Identity.
I'm doing the following:
1. create specific EntityObject using CreateObject method of ObjectContext,
2. I'm leaving ID field unset (it's value is 0 by default),
3. I'm adding EntityObject to EntitySet,
4. and call SaveChanges.
Record is created in database with valid sequenced ID value (for example: 12).
[b]EntityObject's ID is still set to 0.[/b]
Question:
What can be done to force EF to refresh ID value after calling SaveChanges?
Thank you in advance.
PS. I went through the forum and found that I'm doing it right but it seems to be not working for me. Maybe I'm missing something?
PS.2. I have investigated SQL statement logged by dbMonitor and there were only insert statements. I would guess there should be some select added to insert statement for retreiving new ID.