What is difference between dbcontext.Add and dbcontext.AddObject
i am beginner of WPF. I want to know that what is difference between
dbcontext.Add and dbcontext.AddObject.
private void AddButton_Click(object sender, RoutedEventArgs e)
{
Name employee = new Name();
employee.Name1 = "Test";
dataContext.Names.AddObject(employee);
}
I want to achieve this dbcontext.AddObject(). But it says that : Error 1
'System.Data.Entity.DbSet<WpfApplication9.Name>' does not contain a
definition for 'AddObject' and no extension method 'AddObject' accepting a
first argument of type 'System.Data.Entity.DbSet<WpfApplication9.Name>'
could be found (are you missing a using directive or an assembly
reference?) C:\Users\must\Documents\Visual Studio
2012\Projects\WpfApplication9\WpfApplication9\MainWindow.xaml.cs 49 31
WpfApplication9
Also Suggest me that which one is better. Thank you.
No comments:
Post a Comment