Unable to set User FK in another model (User extends IdentityUser)
I am attempting to establish relationships between my models. For context I'm using EntityFrameworkCore and Identity.
I have a User model (extends IdentityUser) and a Study model.
Studies should have one User, and Users can have multiple Studies.
The first time I tried to establish the relationships I wrote them in the models, like so:
That resulted in the warning
I am now trying to use OnModelCreating to create the relationships in
However this says that
I have henceforth changed
However User should contain a list of
I have a User model (extends IdentityUser) and a Study model.
Studies should have one User, and Users can have multiple Studies.
The first time I tried to establish the relationships I wrote them in the models, like so:
That resulted in the warning
The foreign key property 'Study.UserId1' was created in shadow state because a conflicting property with the simple name 'UserId' exists in the entity type, but is either not mapped, is already used for another relationship, or is incompatible with the associated primary key type.I am now trying to use OnModelCreating to create the relationships in
DBContext instead, like so:However this says that
IdentityUser does not contain a definition for Study and no accessible extension method 'Study' accepting a first argument of type 'IdentityUser' could be foundI have henceforth changed
public IdentityUser? User { get; set; } to public User? User { get; set; } with the same result.However User should contain a list of
Study objects...