首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

EF环境下使用数据库自增主键时异步操作的注意事项

Posted on 2012-11-29 10:09  Alex Geng  阅读(239)  评论(0)    收藏  举报

被各种exception折磨了一整天以后终于发现了问题所在

C#, entity framework, auto increment problem

http://stackoverflow.com/questions/3188194/c-entity-framework-auto-increment-problem

Check in your EDMX model, that the autoincrement field's StoreGeneratedPattern attribute is set to "Identity". In this way, EF knows that the autonumbers are handled by the DB.

Here this is explained better: http://stackoverflow.com/questions/3011764/autonumber-with-entity-framework/3038265#3038265

Patch from MS

http://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=37957