Entity Framework's Scope Identity() method

c# entity-framework

Question

What EntityFramework code corresponds to this SQL code?

select Scope_Identity()

I need to get the ID of the most recent record that I added to the database using EF.

1
2
4/13/2011 8:05:59 AM

Accepted Answer

You need to be certain that your key property is linked to.StoreGeneratedPattern.Identity You may learn more about this setting by dialing (here). When creating a model from an MS SQL database when the key column is specified with, this should be utilized as the default.IDENTITY . After that, calling is sufficient.SaveChanges based on the surroundings and 18 to zz for you.

3
5/23/2017 10:27:14 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow