【发布时间】:2017-03-15 19:44:02
【问题描述】:
几天前,我决定在我的项目中使用工作单元和通用存储库。在搜索I found this solution 之后进行此操作。
在这个模式中,我们有 4 层:
1. UI
2. Model
3. Repository
4. Service
重点是所有领域模型都继承自模型层中的Entity 类。例如:
public class Project : Entity<int> {
...
}
这是我的Entity 课程:
public abstract class BaseEntity { }
public abstract class Entity<T> : BaseEntity, IEntity<T>
{
public virtual T Id { get; set; }
}
现在,当我想将 ApplicationUser 类添加到 UoF 模式时,我收到了一个错误,即 ApplicationUser 不是从 BaseEntity 继承的。
提示:
ApplicationUser继承自IdentityUser类
将ApplicationUser 添加到我的设计模式中的最佳做法是什么?
更新
我在IApplicationUserService界面收到错误信息
public interface IApplicationUserService : IEntityService<ApplicationUser>
{
Task<Part> GetById(int? id);
}
IEntityService:
public interface IEntityService<T> : IService
where T : BaseEntity
{
void Create(T entity);
void Delete(T entity);
Task<List<T>> GetAllAsync();
IEnumerable<T> GetAll();
Task Update(T entity);
}
【问题讨论】:
-
请显示错误本身。目前尚不清楚它来自哪里。
-
请再看一遍。
标签: c# asp.net-mvc entity-framework asp.net-identity