MySql + EntityFramework "Backmodel have changed"

I'm working in an App (WinForm + ServiceStack WebServices) and in the AppHost when I try to store some data in a MySql db get this error:

I haven't changed the model. How can I solve this?

Here is MyDbContext

public class MySqlContext : System.Data.Entity.DbContext
    {
        public System.Data.Entity.DbSet<LoginModel> LoginModels { get; set; }
        public System.Data.Entity.DbSet<Role> Roles { get; set; }
        public System.Data.Entity.DbSet<Permission> Permissions { get; set; }

        public MySqlContext()
            : base("ConnectionStringName")
        {
            Database.SetInitializer <MySqlContext>(null);

        }


        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {


            modelBuilder.Entity<LoginModel>().HasMany(lm => lm.roles).WithMany(r => r.Users)
                  .Map(
                      m =>
                      {
                          m.MapLeftKey("lm_Id");
                          m.MapRightKey("role_Id");
                          m.ToTable("login_roles");
                      }
                  );

            modelBuilder.Entity<Role>().HasMany(r => r.Permissions).WithMany(p => p.Roles)
                .Map(
                    m =>
                    {
                        m.MapLeftKey("role_id");
                        m.MapRightKey("per_id");
                        m.ToTable("roles_permissions");
                    }
                );



        }

    }

Answers


Try

Database.SetInitializer<YourDbContext>(null);

In your DbContext

For Example

public class MyDbContext : DbContext
{
    public MyDbContext ()
    {
        Database.SetInitializer<MyDbContext >(null);
    }

    public DbSet<Users> Users { get; set; }    
}

Need Your Help

Selecting/excluding sets of columns in pandas

python pandas dataframe

I would like to create views or dataframes from an existing dataframe based on column selections.