I am going to get mad. I have a so simple code but it doesn't work.
I have tested every thing and I can't understand the reason.
The code is like this:
FataDBEntities model = new FataDBEntities();
UserAccount nua = new UserAccount();
nua.username = username;
nua.pass = password;
nua.email = mailaddress;
nua.activated = false;
model.UserAccounts.Add(nua);
try
{
model.SaveChanges();
}
catch (Exception)
{
throw;
}
string activationCode;
try
{
activationCode = genActivationCodeAndMail(mailaddress, username);
}
catch (Exception)
{
throw;
}
ActivationCode ac = new ActivationCode();
ac.code = activationCode;
ac.expiration_date = DateTime.Now.AddDays(1);
nua = model.UserAccounts.Single(p => p.username == username);
ac.wichUser = nua.ID;
model.ActivationCodes.Add(ac);
try
{
model.SaveChanges();
}
catch (Exception)
{
throw;
}
and the model is like this :
The error is with second insertion ... the first one works fine.
Additional information: Unable to update the EntitySet 'ActivationCode' because it has a DefiningQuery and no element exists in the element to support the current operation.
Please help...