I get the following error when I fill out my form in my MVC Application:
UpdateException was unhandled by user code
Unable to update the EntitySet 'Customer' because it has a DefiningQuery and no <InsertFunction> element exists in the <ModificationFunctionMapping> element to support the current operation.
My Customer table has: ID (PK), Name, Age, Address and a TimeStamp.
The form only allows Name and Address to be filled out (don’t know why – I’m new to MVC, ADO.NET btw)
This is my code:
[HttpPost]
public ActionResult Create(Customer customer)
{
customer.ID = 5;
db.Customers.AddObject(customer);
db.SaveChanges();
return View();
}
I am leaving customer.ID = 5 as a hard coded temp solution for the time being.
If
IDis your primary key, Why you are updating that ? You should be updating the rest of the properties.