首页 新闻 会员 周边 捐助

EF Core 报错:"Unable to cast object of type 'System.Byte' to type 'System.Int32'"

0
悬赏园豆:30 [已解决问题] 解决于 2025-05-30 22:15

对应的实体字段如下,BlogCategoryType 是 enum 类型

public class BlogCategory
{
    public BlogCategoryType CategoryType { get; set; }
}

数据库中 CategoryType 字段类型是 tinyint

dudu的主页 dudu | 高人七级 | 园豆:24691
提问于:2025-05-30 21:34
< >
分享
最佳答案
0

通过 HasConversion 解决了

builder.Property(c => c.CategoryType).HasConversion<byte>();
dudu | 高人七级 |园豆:24691 | 2025-05-30 22:15
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册