I'm using Entity Framework, Asp.net Identity and MVC in c# in order to create my website.
Trying to implement a "group" feature I've been facing a problem... I implemented the casual (based on this : Create code first, many to many, with additional fields in association table):
public class ApplicationUser : IdentityUser
{
[...]
public virtual List<Group> Groups { get; set; }
}
And :
public class Group
{
public int GroupID { get; set; }
[Required]
[StringLength(100, MinimumLength = 2)]
public string Name { get; set; }
public virtual List<ApplicationUser> Members { get; set; }
}
And the link class with an extra attribute (status) :
public class ApplicationUserGroup
{
[Key, Column(Order = 0)]
public string ApplicationUserId { get; set; }
[Key, Column(Order = 1)]
public int GroupId { get; set; }
public virtual ApplicationUser ApplicationUser { get; set;}
public virtual Group Group { get; set; }
// 1 : simple member
// 2 : administrator
public int Status { get; set; }
public ApplicationUserGroup()
{
Status = 1;
}
}
I managed to get my table into my DB as ApplicationUserGroups but Entity keep generating another table GroupApplicationUsers without my status field...
I believe the problem comes from Identity, anyone to help me ?
PS: Sorry for my english, I'm french ^^