I am battling to work out how to handle foriegn keys with Entity Framework, when editing or adding a new record. For example, I have a person table, which has a timezone_id linking to my timezone table.
But the model seems to not include timezone_id. I see it's a new way of doing things, but ... how do I store my record?
My method:
public static string CreateUser(string username, string email, string password, string firstname, string surname, int timezoneId)
{
user u = new user();
u.surname = surname;
u.firstname = firstname;
u.email = email;
u.password = password;
u.username = username;
Db.AddTousers(u);
Db.SaveChanges();
return username;
}
I can't do u.timezone_id = timezoneid;
I only have u.timezone (which seems to be the actual entity), and u.timezoneReference, which I am not sure what to do with.