I want to get the last entry into the database, I usually used SCOPE_IDENTITY() in ado.net to get the last created id, but how to achieve that in Linq-to-SQL or Linq-to-Entities?
For instance I need to get the last added bookingID from the booking table whose userID=xxxx.
Both linq-to-sql and EF do this automatically. You just need to insert an object, save/submit changes and check id property in your object. If correctly configured it should be filled with scope identity.
StoreGeneratedPattern.IdentityIsDbGenerated = true(Auto Generated Value in dbml designer)