Connect with Peer Bloggers

Get your Bloggers ID and network with best bloggers around the world.

9

Many to many relationship in Entity Framework

Czetsuya
czetsuya's tech ― An example of many-to-many relationship is asp's membership tables, between aspnet_Users and aspnet_Roles.Usually we declare it like this:public class AspUser { public Guid UserId { get; set; } ... public ICollection AspRoles { get; set; }}public class AspRole { public Guid RoleId { get; set; } ... public ICollection AspUsers { get; set; }}This will create a new table AspUsersAspRoles with UserId, and RoleId as columns.If you want to define your own table name (example AspUsersInRoles) you[...]

Voted by 1 User



What would you say?

Be the first to comment on this blog post! Sign in or Create an account.