Get Record ID in Entity Framework after insert

前端 未结 4 1395
北荒
北荒 2021-02-07 02:34

I\'m developing an ASP.net application using Entity Framework. I\'m using DetailsView to insert data into database. There is a table as Client and its

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-07 03:17

    After you have inserted the entity it should be updated so that the property that maps to the primary key in the database has the new PK value.

    Like MyObject.Id will give you the new Id

提交回复
热议问题