Ho 2 tabelle, Table1 ha una chiave primaria 'CustomizationId', e Table2 ha un Customizationid FK che corrisponde a questo. Table2 non ha chiave primaria.Come si aggiorna una tabella con una chiave esterna a un'altra tabella in ADO.Net Entity Model?
Sto tentando di aggiungere un nuovo record da un modulo basato sul web. Tento di salvare questo alla base di dati ed ottengo un errore:
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();
Quando chiamo SaveChanges sto ottenendo un errore, anche se non aggiungo nella linea commentata.
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.
Come posso gestire questa situazione? Voglio solo aggiungere il codice nello stesso momento in cui aggiungo la personalizzazione. La tabella 'Codice' dovrebbe avere il Customizationid impostato su PK/Identity impostato dalla personalizzazione.
Qualche idea?