Generating Entity Keys

Posted by David Veeneman on Stack Overflow See other posts from Stack Overflow or by David Veeneman
Published on 2010-03-19T19:33:16Z Indexed on 2010/03/19 23:11 UTC
Read the original article Hit count: 675

Filed under:
|

I have run into my first dissapointment with Entity Framework 4. It turns out that SQL CE, when used with EF4, does not support autogenerated primary keys. I get a System.Data.UpdateException from OnjectContext.SaveChanges() with this message:

Server-generated keys and server-generated values are not supported by SQL Server Compact.

So, now I have to manually generate keys for my entities. Assuming I want to use auto-incremented integer keys, what is the best way to go about generating and keeping track of the keys when using Entity Framework? Thanks for your help.

© Stack Overflow or respective owner

Related posts about entity-framework

Related posts about sqlce