0

I am beginner to Entity Framework.

Let's say I have a Person Entity and I need to add a new Person to Database.

My Database has a Person Table with Id, Name, Age, and email. where id is the PK.

To add a new Person. My code will look:

DatabaseEntities context = new DatabaseEntities();
Person p = new Person("name", age, "email");
context.AddToPersons(p);
context.SaveChanges();

My Question is: After adding the new person, How can I get the id of that person.

1 Answer 1

4

The id should automatically be set by the context.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.