Click here to Skip to main content
15,887,852 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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();
                    }
                }



Here is Entity setup...
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;


What I have tried:

I did notice an error, early on, indicating that the table does not have a primary key but I corrected that, deleted the edmx, and re-generated everything.

fun stuffs! :(
Posted
Updated 2-Oct-18 14:00pm
v2

1 solution

OK,
Holy carelessness, Batman!

I had originally pointed server connection to where the same table name was located that did NOT have a primary key so entity was created with read-only table.

Fortunately, I was able to drop the EDMX and re-generate it after pointing to the correct server.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900