I have asp.net mvc5 project, with default authentication (AccountController)
I would like to allow user to create some objects of type, lets say "MyEntity", and I would like to record it to DB. How to perform this stuff with Entity Framework Code First ?
(i.e. I want something like:
class MyEntity
{
public Guid MyEntityId { get; set; }
public String Name { get; set; }
public User CreatedByUser { get; set; } // Those line I'm asking for ???
}
)
[Update]
Ok, I reached point, I needed. First:
public class MyUser : IdentityUser
{
}
Second:
public class MyDataContext : IdentityDbContext<MyUser>
{
public MyDataContext()
: base("MyEntitiesConnection")
{
}
}
Third:
public class MyEntity
{
//....
public MyUser User { get; set; }
}
And it's put relationship as foreign key to DB