Skip to Main Content

ODP.NET

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Entity Framework - Not possible to use auto incrementing primary keys?

887367Sep 9 2011 — edited Sep 29 2011
I have a basic employee table with a primary ID column that is filled using a sequence in a before insert trigger. Consider the following code example:

-----

var models = new EntityContainer();
var employee = new Employee() { FirstName = "Joe", LastName = "Blow", Email = "joe.blow@company.com" };

models.Employees.AddObject(employee);
models.SaveChanges();

Console.WriteLine(employee.ID); // Always prints '0'

-----

This will successfully save the entity to the database, but my understanding is that when I set the StoreGeneratedPattern attribute of my Employee model to Identity, that the ID column will be read back from the database after the submit. This is not the case. The ID is not filled, and as a result the entity is essentially lost, as without knowing the primary key there is no guaranteed way of ever retrieving it again.

Is this a bug/missing feature, or am I missing something. For the record, this sample works perfectly when using SQL Server.

Edited by: 884364 on Sep 9, 2011 3:49 PM

Edited by: 884364 on Sep 9, 2011 3:51 PM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 27 2011
Added on Sep 9 2011
3 comments
4,128 views