c# - Does saving to context in MVC update object attributes? -


I was wondering if it always happens that ASP saves an object in an MVC to an object with DB?

Just ask for example that I have a student class with field ID and where is the name

the key to the records is clearly ID

If I have a student: student student = new student ("student name");

and do

  context. Insert (student); Id will be assigned a number reference. Save ();   

After such operation, it is assumed that the "student" ID has been updated? Or do I have to ask it to the database.

Thanks

OK. .. depends on! :) You are describing a case where EF conferences are doing something for you. Code First Conference looks for those areas which have been named ID or [class name] ID and it determines that The keys are for the classes. You class design just match this conference. Because you have ID property integer type, EF has also configured it to be the identity column in the database. Therefore, when you save your object, it creates your database ID and the reference is partially updated.

Regarding documentation, Julia Lerman wants about three EF books.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -