Entity Framework MySQL tinyint(1) System.Boolean.Parse FormatException

后端 未结 3 439
梦如初夏
梦如初夏 2021-01-12 01:18

I\'m using EntityFramework 6 in my C# model-first project which using a MySQL database. Everything was fine and I could ge

3条回答
  •  悲&欢浪女
    2021-01-12 02:12

    Configure the datatype on a specific Entity:

    modelBuilder.Entity()
                      .Property(p => p.Active)
                      .HasColumnType("bit");
    

    or general:

    modelBuilder.Properties()
                .Where(x => x.PropertyType == typeof(bool))
                .Configure(x => x.HasColumnType("bit"));
    

提交回复
热议问题