获取实体框架中新生成的ID(即scopeIdentity) [英] Get Newly generated ID (i.e. scopeIdentity) in Entity FrameWork

查看:218
本文介绍了获取实体框架中新生成的ID(即scopeIdentity)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的表添加一条记录例如订单。添加记录后,我想插入记录的新生成的ID。像 SCOPEIDENTY 中的SQL。

I am added a record in my table e.g. Orders. After adding the record i want to get the newly generated ID of the inserted record. Like SCOPEIDENTY in SQL.

但我怎么能做到这一点的实体框架。

But how can i do this in Entity Framework.

推荐答案

在您保存更改,你的实体对象应该自动地反映新生成的ID。这是关于实体框架的许多伟大的事情之一。 : - )

After you saved your changes, your entity object should reflect the newly generated ID automagically. It's one of the many great things about the Entity Framework. :-)

这篇关于获取实体框架中新生成的ID(即scopeIdentity)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆