EF Code First composite key mapping -


i have 2 tables. user , roles.one user can have meany roles. created table called roleuser. how should implement in code first(i want insert , update operation)

thanks in advance

natively should able declare 2 tables (with properties pointing other) , ef pick on many-to-many relationship (and create intermediary table 2 fk's)

public class user {     public int id { get; set; }     public string username { get; set; }      // user can within multiple roles     public icollection<role> roles { get; set; } } public class role {     public int id { get; set; }     public string name { get; set; }      // role can have many users     public icollection<user> users { get; set; } } 

Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -