I have a database table in SQL Server 2008 that utilizes uniqueidentifier as its primary key. The newid() method on the database side is used to produce the key for inserts.
ADO.NET has no issues with this. However, there is a difficulty when I put up this table as an entity in an Entity Framework 4 model. I have no trouble querying the entity, but when I create a new entity and call SaveChanges() on the context, the database's created unique identifier contains just zeros.
I know that EF v1 had a bug that prevented this situation from working, necessitating the creation of the GUID on the client before invoking SaveChanges. But I had read several times that they intended to address issue with EF 4.
I want to know whether EF4 still does not enable this case (DB-side creation of uniqueidentifier). Do we have to continue creating the GUID on the client?
Thank you, I've worked it out at last. The solution was blogged here:
Yes, this was changed in EF 4. @MusiGenesis, server-generated GUIDs may be consecutive, for example, which is one benefit.