小编And*_*nho的帖子

Entitiy Framework Core preview 2 - default value for boolean

We were using .Net Core 1 and we migrated to Preview 2 (both with Entity). Before migration, we used to set a default value for a boolean in Entity Framework like this:

modelBuilder.Entity<Customer>()
  .ToTable("Customer")
  .Property(a => a.Active)
  .HasDefaultValue(true);
Run Code Online (Sandbox Code Playgroud)

After migration, we didn't change anything but now we are getting an error when entity tries to create this table. It looks like it is trying to create a default value as string like "True" and not as a bit, like before. …

.net c# entity-framework-6 asp.net-core

5
推荐指数
1
解决办法
2682
查看次数

标签 统计

.net ×1

asp.net-core ×1

c# ×1

entity-framework-6 ×1