Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

entity save example in c# model first

// disconnected new entity 
var student = new Student(){ StudentName = "Bill" };

using (var context = new SchoolDBEntities())
{
    context.Entry(student).State = student.StudentId == 0? EntityState.Added : EntityState.Modified;

    context.SaveChanges();
}
Source by www.entityframeworktutorial.net #
 
PREVIOUS NEXT
Tagged: #entity #save #model
ADD COMMENT
Topic
Name
9+9 =