I have a Razor Pages web app that was created in Visual Studio on Window 10. The app all works fine as intended.
I am now wanting to run this on a Mac as I no longer have access to a Windows machine. I have setup the connection to the MySql database and the connection seems to be there.
However I am getting the following error message
An unhandled exception occurred while processing the request.
MySqlException: Unknown column 'u.AccessFailedCount' in 'field list'
MySql.Data.MySqlClient.MySqlStream.ReadPacket()
I think it could be due to the tables etc missing however I'm unsure on how to generate/build the tables on a Mac, as normally Entity Framework would handle this.
I may (I think) have solved the issue I am facing however I'm not sure if it is the best solution. I have the below class for the ApplicationDbContext
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
: base(options)
{
this.Database.EnsureDeleted();
this.Database.EnsureCreated();
}
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
}
}
Adding the 2 lines below
this.Database.EnsureDeleted();
this.Database.EnsureCreated();
and running the code then removing them afterwards seemed to solve the issue.