开发者

EF4 and Server Generated UniqueIdentifier Id

Does Entity Framework 4 not yet support having the guid Id generated at the server upon insert? I have my Id fields set to have a default value of newid(), but Entity Framework is setting the value to the empty guid. I end up with an empty guid in the database and an empty guid in the id field of my object. Is this not yet supported or do I need to changes so开发者_如何学Gomething on my model?


Found the solution. Basically the entity framework markup isn't generated properly.

http://leedumond.com/blog/using-a-guid-as-an-entitykey-in-entity-framework-4/
(broken link, redirects to publicity)


There's a problem with the Entity Designer in Visual Studio, which means that updating the "StoreGeneratedPattern" field doesn't correctly update the generated code. In turn, this means EF passes the entity's GUID to the SQL Server, so the server doesn't run newid() or newsequentialid().

As David says, Microsoft have released a patch.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜