I have 2 tables for Users, one to hold User common info and one for extra info, they have one to one relation with UserId field.
Users:
UserId >> Primarykey auto increment
UserName
Password
UsersInfo:
UserId >> Primarykey
MoreInfo
in my application , when the user register a new account we insert a row in Users table, and later if he wanted to change some info, we need to add to UsersInfo table.
The problem I am facing is that when I try to insert in the UsersInfo table it always tell me that UserId can’t be null. while I have this userId set before i call saveChanges.
var info = new UserInfo { UserId = userId, MoreInfo = text };
context.UserInfo.Add(info);
I don’t know if the problem in EF or in db, so any info or something to check will help.
This is not a solution but workaround.
It probably will work: