I'm trying to add asp.net identity to my existing project. I want to use the table "Customer" for users.
this is my Customer class :
public partial class Customer : IdentityUser<int, CustomerLogin, AspNetRole, CustomerClaim>
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
public Customer()
{
this.Quotes = new HashSet<Quote>();
this.Bookings = new HashSet<Booking>();
this.CustomerClaims = new HashSet<CustomerClaim>();
this.CustomerLogins = new HashSet<CustomerLogin>();
this.AspNetRoles = new HashSet<AspNetRole>();
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<Customer, int> manager)
{
// Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
// Add custom user claims here
return userIdentity;
}
public int Id { get; set; }
public string Password { get; set; }
public System.DateTime CreationDate { get; set; }
public System.DateTime UpdateDate { get; set; }
public override string UserName { get; set; }
public override ICollection<CustomerClaim> Claims => this.CustomerClaims;
public virtual Country Country { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<Quote> Quotes { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<Booking> Bookings { get; set; }
public virtual Location Location { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<CustomerClaim> CustomerClaims { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<CustomerLogin> CustomerLogins { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<AspNetRole> AspNetRoles { get; set; }
}
The first insertion pass, but when i attempt to inset a new user iget this error:
The 'Claims' property on the 'Customer' type is not a navigation property. The Reference and Collection methods can only be used with navigation properties. Use the Property or ComplexProperty method.
any idea ?