I have 2 tables, Table1 has a primary key 'CustomizationId', and Table2 has a FK Customizationid which matches this. Table2 has no primary key.
I am trying to add a new record from a web based form. I attempt to save this to the database and I get an error:
Customization customization = new Customization();
Code code = new Code();
customization.Name = CustomizationName.Text;
customization.LastUpdated = DateTime.Now;
code.Top = top_js.InnerText;
code.Bottom = bottom_js.InnerText;
//code.CustomizationId = customization.CustomizationId;
customization.Code = code;
entities.AddToCustomizations(customization);
entities.SaveChanges();
When I call SaveChanges I am getting an error, whether or not I add in the commented line.
Unable to update the EntitySet 'Code' because it has a DefiningQuery and no <InsertFunction> element exists in the <ModificationFunctionMapping> element to support the current operation.
How do I handle this situation? I just want to add in the code at the same time that I add in the Customization. The 'Code' table should have the Customizationid set to the PK/Identity set by Customization.
Any ideas?