I'm new to Entity Framework, and I'm think there is something that I misunderstand here. I'm trying to insert a row in a table, and everywhere I found code example, they call the method InsertOnSubmit(), but the problem is that I can't find anywhere the method InsertOnSubmit, or SubmitChanges.
The error tell me: System.Data.Object.ObjectSet do not contain the definition for InsertOnSubmit, ...
What I'm doing wrong??
http://msdn.microsoft.com/en-us/library/bb763516.aspx
GMR_DEVEntities CTX;
CTX = new GMR_DEVEntities();
tblConfig Config = new tblConfig { ID = Guid.NewGuid(), Code = "new config code" };
CTX.tblConfigs.InsertOnSubmit(Config); // Error here
Edit: Using Visual Studio 2010 on FW 4.0
Finally found what was wrong, my Entity database was a dbmx file and not a dbml file. I do not understand why this .. but has long as it work. (Need to buy a new book I guess) – Hugo Feb 17 at 19:40
i also have the same problem .we can insert by using Add
InsertOnSubmit
is a Linq-to-SQL method and not in the Entity Framework.However, since our project was a conversion from Linq-to-SQL we have some extension methods that might help:
Where
EntityHelper
is as per the MyExtensions open source library.Hello this works for me