I have an IdentityDbContext like this:
public class MyIdentityContext : IdentityDbContext<AppUser, AppRole, int>
{
public DbSet<App> Apps { get; set; }
public DbSet<Team> Teams { get; set; }
public DbSet<Avatar> Avatars { get; set; }
public DbSet<Device> Devices { get; set; }
public DbSet<Subscription> Subscriptions { get; set; }
public MyIdentityContext(DbContextOptions<MyIdentityContext> options) : base(options)
{
} // ctor
} // Cls
If I add a property to App, Team Device, etc I can add a migration and update the database just fine.
Example:
public class Team
{
public int Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public ICollection<AppUser> Members { get; set; }
public string ABD { get; set; } <--NEW PROPERTY
} // Cls
However if I do the same in my AppUser class:
public class AppUser : IdentityUser<int>
{
public string FirstName { get; set; }
public string LastName { get; set; }
/// <summary>
/// What app is this user connected to.
/// </summary>
public string ApplicationName { get; set; }
/// <summary>
/// Where does the employee work
/// </summary>
public string Company { get; set; }
/// <summary>
/// What section of the company does the employee work in.
/// </summary>
public string Department { get; set; }
/// <summary>
/// Maximum device this user can use - 0 means unlimited
/// </summary>
public int DeviceLimit { get; set; } = 0;
/// <summary>
/// This users avatar
/// </summary>
public Avatar Avatar { get; set; }
/// <summary>
/// Devices connected to this user
/// </summary>
public ICollection<Device> Devices { get; set; }
/// <summary>
/// Teams that this user is a member of
/// </summary>
public ICollection<Team> Teams { get; set; }
/// <summary>
/// Apps that this user is subscribed to
/// </summary>
public ICollection<Subscription> Subscriptions { get; set; }
public string ABD { get; set; } <--NEW PROPERTY (causes error)
public AppUser()
{ }
} // Cls
I get the following error:
An error occurred while accessing the Microsoft.Extensions.Hosting services. Continuing without the application service provider.
Error: One or more errors occurred. (Invalid column name 'ABD'.)
What am I doing wrong?