rahul jaiswal

rahul jaiswal

  • 1.7k
  • 252
  • 113.3k

Entity C# add class which inherits from other

Aug 27 2012 8:44 AM

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 ();
.UserID = user.UserID;
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.

Brought to you by:

Answers (1)