Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Model with Identity User FK

$
0
0

Hi

I am using asp.net core website with Identity where Client details are captured.

All has been working fine, both creating clients and the user authentication.

But now I want to assign a client to an Identity User (A ClientSupport person).

I thought updating the Client Model like this should work:

    public class Client
    {
        public int ID { get; set; }
        public string ClientName { get; set; }public virtual ApplicationUser ClientSupport { get; set; }

    }

And updating the ApplicationUser model like this:

    public class ApplicationUser : IdentityUser
    {public int ID { get; set; }
        public virtual ICollection<Client> Clients { get; set; }
    }

But when I try to add the Migration to update the database, I get the following error...

The entity type 'Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUserLogin<string>' requires a primary key to be defined.

Any help with this would be appreciated.


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>