Abpvnext 扩展AbpUsers表数据库字段后,希望使用AppUser实体去进行EF查询过滤数据
结果执行到查询时抛如下异常
错误提示信息无太大参考意义
在.EntityFramework项目DbContext中
添加了AppUser与IdentityUser的一对一的映射关系,此异常解决
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
builder.Entity<AppUser>(b =>
{
// AbpUsers
// Sharing the same table "AbpUsers" with the IdentityUser
b.ToTable(AbpIdentityDbProperties.DbTablePrefix + "Users");
b.ConfigureByConvention();
b.ConfigureAbpUser();
b.HasOne<IdentityUser>().WithOne().HasForeignKey<AppUser>(x => x.Id);
// WeChatUnionId
b.Property(x => x.WeChatUnionId)
.IsRequired(false)
.HasMaxLength(32)
.HasColumnName("WeChatUnionId");
// IdCard
b.Property(x => x.IdCard)
.IsRequired(false)
.HasMaxLength(20)
.HasColumnName("IdCard");
// Sex
b.Property(x => x.Sex)
.HasDefaultValue(SexEnum.UnKnown)
.HasColumnName("Sex");
});
builder.ConfigurePermissionManagement();
builder.ConfigureSettingManagement();
builder.ConfigureAuditLogging();
builder.ConfigureIdentity();
builder.ConfigureBaseService();
}