Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EF ObjectContext.SaveChanges is missing

I am working with Entity Framework on a new Project. I've been using EF since a year ago. Today i've tried to generate Entity Data Model with Visual Studio (2008 SP1 and 2010) and it is generating object context properties and entitysets but has not generated SaveChanges method. I've even tried with databases that i've used previosuly to generate entity data models. I don't know what's happening. I used my laptop and my desktop but is not working on both even when i've done it before in both.

My Enviroment is:

Visual Studio 2008 SP1. SQL Server 2008 Express. Web Client Software Factory Feb 2008 Release.

like image 815
Jhonny López Avatar asked Sep 16 '10 19:09

Jhonny López


3 Answers

Probably late, but you need to include System.Data.Entity namespace to get this extension method.

like image 63
Stavros Mavrokefalidis Avatar answered Sep 24 '22 00:09

Stavros Mavrokefalidis


Inherit your context from DbContext like public class MYContext : DbContext

like image 20
Engineer M Sajjad Avatar answered Sep 22 '22 00:09

Engineer M Sajjad


For more recent people coming here for an answer, you may also need to NuGet the Entity Framework 5.0 (or later) into your project.
A colleague I was just helping had this issue where he used EF 5 in a separate project for the EDMX, but for the project in which he was using the entities, he didn't grab the EF 5 framework. Even with System.Entity.Framework added, and all the other LINQ, Entity, and XML assemblies he tried adding, it still didn't work. I suggested he restart VS2012, and then a few handy errors suddenly showed up regarding the EF 5 Framework.

like image 29
David Storfer Avatar answered Sep 22 '22 00:09

David Storfer