Hi, I'm using ADO.NET Entity framework for my project and I am new at this techonology. There are 2 associated tables, one is "personel" other is "departmant". When I tried to update personel's departmant I am getting this error:
[System.InvalidOperationException] = {"'DEPARTMANID' property is piece of object's key information and can not be changed. "}
Here is my code below for update;
int DepartmantId = 1;
int PersonelID = 2;
try
{
using (FirebirdEntityz fe = new FirebirdEntityz())
{
var query = (from c in fe.PERSONEL.Include("DEPARTMANT") where c.PERSONELID == PersonelID select c).First();
query.NAME = NAME;
query.SURNAME = SURNAME;
query.DEPARTMANT.DEPARTMANTID = DepartmantId;
int result = fe.SaveChanges();
if (result > 0)
{
MessageBox.Show(result + " record updated");
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.InnerException.ToString());
}