Преобразовать bool в bit. EF Core. PostgreSQL
Есть сущность, у которой свойство имеет тип данных в C# bool. Например
public class Entity
{
public int Id { get; set; }
public bool Flag{ get; set; }
}
Можно ли преобразовать bool в bit средствами EF Core для БД Postges?
Пробовал так
modelBuilder.Entity<Entity>()
.Property(x => x.Flag)
.IsRequired()
.HasColumnType("bit");
Но при создании миграции получаю ошибку:
The property 'Entity.Flag' is of type 'bool' which is not supported by the current database provider. Either change the property CLR type, or ignore the property using the '[NotMapped]' attribute or by using 'EntityTypeBuilder.Ignore' in 'OnModelCreating'.
Источник: Stack Overflow на русском