首页 > 代码库 > Found more than one concrete type for given DbContext Type (xxx.xxxx.xxx) define MultiTenancySideAttribute with Tenant

Found more than one concrete type for given DbContext Type (xxx.xxxx.xxx) define MultiTenancySideAttribute with Tenant

错误提示:

Found more than one concrete type for given DbContext Type (Abp.Zero.EntityFramework.AbpZeroCommonDbContext`2[Easyman.Authorization.Roles.Role,Easyman.Users.User]) define MultiTenancySideAttribute with Tenant. Found types: Easyman.EntityFramework.EasymanDbContext, Easyman.EntityFramework, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null, Easyman.EntityFramework.EmProjectDbContext, Em.Project.EntityFramework, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.

技术分享


 

错误原由:找到满足User的映射的多个DbContext

我的项目中,EF有多级继承,继承结构如下:

public abstract class EasymanDbContext : AbpZeroDbContext<Tenant, Role, User>

public class EmProjectDbContext: EasymanDbContext

此处有一个细节处理:应该将继承AbpZeroDbContext的子类EasymanDbContext 设置为抽象类abstract,理由是抽象类不会被实例化

Found more than one concrete type for given DbContext Type (xxx.xxxx.xxx) define MultiTenancySideAttribute with Tenant