EF ObjectContext.SaveChanges is missing

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-07 13:10:47

问题


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.


回答1:


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




回答2:


Inherit your context from DbContext like public class MYContext : DbContext




回答3:


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.



来源:https://stackoverflow.com/questions/3730181/ef-objectcontext-savechanges-is-missing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!