Click here to Skip to main content
15,896,912 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
{"Unable to update the EntitySet 'Addons' because it has a DefiningQuery and no <insertfunction> element exists in the <modificationfunctionmapping> element to support the current operation."}




C#
[HttpPost]
       [ValidateInput(false)]
       public ActionResult AddAddon(AddonModel addmodel)
       {

           if(ModelState.IsValid)
           {
               Addon addonobj = new Addon();
               addonobj.AddonTitle = addmodel.AddonTitle;
               addonobj.Price = addmodel.Price ?? 0;
               addonobj.Description = addmodel.Description;
               addonobj.Status = true;
               addonobj.CreatedDate = addmodel.CreatedDate;
               addonobj.UpdatedDate = addmodel.UpdatedDate;
               snw.Addons.Add(addonobj);
               snw.SaveChanges();
               return RedirectToAction("List");
           }

           return View();
       }
Posted
Updated 15-Dec-15 0:23am
v3
Comments
Amit Jadli 15-Dec-15 6:31am    
Make sure that your table has a primary key ! If not add the key and update the Entity Framework model.

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