Relationship many to many avec EF
Bonsoir bonsoir,
je souhaite mettre une relation Many to many sur deux entitées avec Entity Framework.
voici le code des entitées
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| [Table("UserProfile")]
public class UserProfile
{
[Key]
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
public int UserId { get; set; }
public string UserName { get; set; }
public ICollection<GroupModel> Groups { get; set; }
[DataType(DataType.DateTime)]
public DateTime DateOfBirth { get; set; }
[DataType(DataType.EmailAddress)]
public string Email { get; set; }
public string Department { get; set; }
public string Title { get; set; }
public string Gender { get; set; }
} |
Code:
1 2 3 4 5 6 7 8 9
| public class GroupModel
{
[Key]
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
public string Name { get; set; }
public UserProfile Author { get; set; }
public ICollection<UserProfile> Menbers { get; set; }
} |
Comment faire pour que les Propriétées Groups et Menbers donne lieu a la creation de table. Ou faire comme @ManytoMany en java ?