I\'m using EntityFramework 6 in my C# model-first project which using a MySQL database. Everything was fine and I could ge
This can also be achieved using the Column
data attribute within the Entity.
[Column("Active", TypeName = "bit")]
[DefaultValue(false)]
public bool Active { get; set; }
If you are doing this DB first, simply change the TINYINT(1) types to BIT(1), assuming you really want a Boolean. You may have to update the default values also (to bit syntax such as b'0'). EF will still translate these to Boolean values in your entities.
Configure the datatype on a specific Entity:
modelBuilder.Entity<User>()
.Property(p => p.Active)
.HasColumnType("bit");
or general:
modelBuilder.Properties()
.Where(x => x.PropertyType == typeof(bool))
.Configure(x => x.HasColumnType("bit"));