Rijen Juni

Rijen Juni

  • NA
  • 16
  • 7.1k

Insert Foreign Key

Aug 20 2015 1:47 AM
I would to insert data from my controller to table customer which have a foreign key from active_customer, no_peserta is the foreign key which refer to active_customer table its my code
 
var cus = new Customer {
no_peserta =17,
 nama_customer=nama,
no_ktp=noktp,
no_hp=nohp,
tanggal_lahir=tgllahir
};
context.Customer.Add(cus);
 context.SaveChanges();
but till now its still not work .If you have solution for this please tell me
The error page says " An exception of type 'System.Data.Entity.Infrastructure.DbUpdateException' occurred in EntityFramework.dll but was not handled in user code

Additional information: 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."

Answers (2)