mmajic
mmajic
CC#
Created by mmajic on 11/29/2023 in #help
IdentityServer update database error when multiple user types.
I am using IdentityServer in dotnet. I have a base type EntityUser that inherits the IdentityUser<int> class. The entityuser is a base class for multiple user types. After creating a migration successfully with add-migration Test and run update-database I get the following error:
There is already an object named 'AspNetRoles' in the database.
There is already an object named 'AspNetRoles' in the database.
Here are the relevant classes: EntityUser.cs
public class EntityUser : IdentityUser<int>
{
public bool Active { get; set; }
public decimal Credits { get; set; } = 0;
public virtual ICollection<EntityUserRole> UserRoles { get; set; } = new List<EntityUserRole>();
}
public class EntityUser : IdentityUser<int>
{
public bool Active { get; set; }
public decimal Credits { get; set; } = 0;
public virtual ICollection<EntityUserRole> UserRoles { get; set; } = new List<EntityUserRole>();
}
ClubAdmin.cs
public class ClubAdmin : EntityUser
{
public virtual ICollection<Club> Clubs { get; set; } = new List<Club>();
// other clubadmin specific properties
}
public class ClubAdmin : EntityUser
{
public virtual ICollection<Club> Clubs { get; set; } = new List<Club>();
// other clubadmin specific properties
}
DJ.cs
public class DJ : EntityUser
{
public virtual ICollection<Club> Clubs { get; set; } = null!;
public PayoutMethod PayoutMethod { get; set; }
//other specific properties
}
public class DJ : EntityUser
{
public virtual ICollection<Club> Clubs { get; set; } = null!;
public PayoutMethod PayoutMethod { get; set; }
//other specific properties
}
2 replies