Why am I getting a "Unable to update the EntitySet because it has a DefiningQuery..." exception when trying to update a model in Entity Framework?

Viewed 22169

While updating with the help of LINQ to SQL using Entity Framework, an exception is thrown.

System.Data.UpdateException: Unable to update the EntitySet 't_emp' because it has 
a DefiningQuery and no <UpdateFunction> element exists in the   
<ModificationFunctionMapping>

The code for update is :

public void Updateall()
    {
        try
        {


            var tb = (from p in _te.t_emp
                      where p.id == "1"
                      select p).FirstOrDefault();
            tb.ename = "jack";

            _te.ApplyPropertyChanges(tb.EntityKey.EntitySetName, tb);
            _te.SaveChanges(true);
        }
        catch(Exception e)
        {

        }
    }

Why am I getting this error?

3 Answers
Related