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: and do 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. student student = new student ("student name");
context. Insert (student); Id will be assigned a number reference. Save ();
Comments
Post a Comment