Почему entity framework выдает эту ошибку?
ex.Message = "Unable to update the EntitySet 'ExternalEmployees' because it has a DefiningQuery and no <UpdateFunction> element exists in the <ModificationFunctionMapping> element to support the current operation."
if(externalEmployeeDataGrid.IsVisible) { ExternalEmployee selectedEmployee = (ExternalEmployee)externalEmployeeDataGrid.SelectedItem; ExternalEmployee ExtEmpContext = this.context.ExternalEmployees.Find(selectedEmployee.ID); if(ExtEmpContext != null) { ExtEmpContext.BadgeNo = selectedEmployee.BadgeNo; ExtEmpContext.EmployeeName = selectedEmployee.EmployeeName; ExtEmpContext.EmployeeType = selectedEmployee.EmployeeType; // ExtEmpContext.Status = selectedEmployee.Status; context.SaveChanges(); } }
Вот настройка сущности...
public ExternalEmployee newExternalEmployee { get; set; } NewMealPlanEntities context = new NewMealPlanEntities(); CollectionViewSource externalEmployeesViewSource; public ExternalEmployeesWindow() { InitializeComponent(); externalEmployeesViewSource = ((CollectionViewSource)FindResource("externalEmployeeViewSource")); DataContext = this; } private void Window_Loaded(object sender, RoutedEventArgs e) { //System.Windows.Data.CollectionViewSource externalEmployeeViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("externalEmployeeViewSource"))); // Load data by setting the CollectionViewSource.Source property: // externalEmployeeViewSource.Source = [generic data source] context.ExternalEmployees.Load(); externalEmployeesViewSource.Source = context.ExternalEmployees.Local;
Что я уже пробовал:
Я действительно заметил ошибку, указывающую на то, что таблица не имеет первичного ключа, но я исправил ее, удалил edmx и заново сгенерировал все.
забавные вещи! :(