I have two classes in my Entity project, User and UserProfile, UserProfile inherit from User.
Some part of my code instantiate new User, than I want to add UserProfile to my sql database, which will be expanding my User class. But I don't know how to write it.
I was trying:
Users user = context.Users.FirstOrDefault(o => o.UserID == UserId);
if (user != null)
{
UserProfile userProfile= new UserProfile ();
userProfile.UserID = user.UserID;
context.Users.AddObject(userProfile);
context.SaveChanges();
return "ok";
}
but it's not working. Writing just pure sql it'd be no problem. But I don't know how to write it properly. Thanks for help.