How to add a foreign key reference to ASP.Net MVC 5 Identity?

后端 未结 3 1871
無奈伤痛
無奈伤痛 2021-01-30 04:16

I have a new ASP.NET MVC 5.1 project using the ASP.Net Identity. It seems reliable and promise, but today i spend almost 9 hours to do a simple things if using SQL.

My p

3条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-30 04:49

    Thanks you Gábor Plesz for comment above.

    I found the solution.

    The ApplicationUser class who inherit IdentityUser (which create AspNetUsers table) should create a ICollection property of the child class (child table).

    e.g.

    public virtual ICollection ToDoes { get; set; }
    

    So the ToDo class can be reference to ApplicationUser

    Highly recommend have a look the sample as Gábor Plesz said.

    enter image description here

提交回复
热议问题