I am trying to relate an ApplicationRole (IdentityRole) to a Parent role as it's type of Role. I would like to understand the Fluent API a little better to accomplish this.
public class ApplicationRole : IdentityRole
{
[StringLength(128)]
[DisplayName("Based On Role")]
public string BasedOnRoleId { get; set; }
[ForeignKey("BasedOnRoleId")]
public virtual ApplicationRole BasedOnRole { get; set; }
}
I currently have something like this that doesn't work...of course:
modelBuilder.Entity<ApplicationRole>()
.HasKey(e => e.BasedOnRoleId)
.HasRequired(e => e.BasedOnRole)
.WithOptional(e => e.??)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.