ASP.NET Core with MySql database. How to change a model's schema?

Viewed 25

I have an ASP.NET Core app and I want to put a model in a different schema, however since I am using MySQL, it is not so simple.

For example I have an employee entity in a schema saas_repare like this:

[Table("erp_empleados", Schema ="saas_repare")]
public class Employee : IdentityUser<ulong>
{
      // Some more fields....
}

But I get this error

A schema "saas_repare" has been set for an object of type "CreateTableOperation" with the name of "ApplicationUser". MySQL does not support the EF Core concept of schemas. Any schema property of any "MigrationOperation" must be null

How can I resolve this issue?

If you need my databse context here it is.

namespace erp_colombia
{
    public class erp_colombiaDbContext : IdentityDbContext<Employee, Entities.Type, ulong>
    {

        public erp_colombiaDbContext(DbContextOptions options) : base(options)
        {
        }

        protected override void OnModelCreating(ModelBuilder builder)
        {
            //Some more builder fields...
            builder.Entity<Employee>();
        }

        public DbSet<Employee> Employees { get; set; }
        //Some more db contexts
    }
1 Answers

You just can't. MySQL doesn't do schemas, it calls databases schemas.

Related