[SOLVED] ASP.NET Core with MySql database. How to change a model’s schema?


This Content is from Stack Overflow. Question asked by J.C

I have a asp.net core app and I want to put a model in a diffrent schema however since I am using mysql it is not so simple.

For example I have a employee schema like this where I have added the schema property.

[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...

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


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

This Question was asked in StackOverflow by J.C and Answered by CodeCaster It is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?