Entity framework Context.SaveChanges not working at all

c#, entity-framework-5, visual-studio-2012

Solution

Make property of .mdf file in your solution as Copy to output Directory: "Copy only if newer"

Otherwise your db file will overwrite every time it runs

Problem

I'm having problems with this code. I´m able to connect to an mdf example database archive and generate the entity model. Althought I´m able to query the context model and retrieve information from the DB, when I try to update, delete or insert anything in the context and translate the changes to the DB Context.SaveChanges is not working. There is no Exception, the Entity model is updated properly, but the DB does not have the change. Thanks in regard ``` public void addCourse(int courseId, int deptId, string courseTitle) { SchoolContexto = new SchoolEntities(); Course mycourse= new Course(); mycourse.CourseID = courseId; mycourse.Credits = 10; mycourse.DepartmentID = deptId; mycourse.Title = courseTitle; SchoolContexto.Courses.Add(mycourse); SchoolContexto.SaveChanges(); SchoolContexto.Dispose(); } ```

Original source