原文:
https://www.cnblogs.com/senyier/p/7298847.html
报错:
An unhandled exception occurred while processing the request.
HandlerException: Can't create component 'BIMMP.OAMS.OAContractSealAppService' as it has dependencies to be satisfied.
'BIMMP.OAMS.OAContractSealAppService' is waiting for the following dependencies:
- Service 'Abp.Domain.Repositories.IRepository`2[[BIMMP.OAMS.OAContractSeal, BIMMP.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.Int32, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]' which was not registered.
Castle.MicroKernel.Handlers.DefaultHandler.AssertNotWaitingForDependency()
原因:
BIMMPDbContext
中忘了加这句 public virtual DbSet<OAContractSeal> OAContractSeals { get; set; }
总结:
数据库里面也有那张表,估计是谁提交代码的时候,把那句代码给冲掉了
全部代码:
IOAContractSealAppService.cs
namespace BIMMP.OAMS
{
public interface IOAContractSealAppService : IApplicationService
{
}
}
OAContractSealAppService.cs
namespace BIMMP.OAMS
{
[AbpAuthorize]
public class OAContractSealAppService : BIMMPAppServiceBase, IOAContractSealAppService
{
private readonly IRepository<OAContractSeal, int> _oAContractSealRepository;
public OAContractSealAppService(
IRepository<OAContractSeal, int> oAContractSealRepository)
{
_oAContractSealRepository = oAContractSealRepository;
}
}
}
BIMMPDbContext.cs
namespace BIMMP.EntityFrameworkCore
{
public class BIMMPDbContext : AbpZeroDbContext<Tenant, Role, User, BIMMPDbContext>
{
public virtual DbSet<OAContractSeal> OAContractSeals { get; set; }
public BIMMPDbContext(DbContextOptions<BIMMPDbContext> options)
: base(options)
{
}
}
}
OAContractSeal.cs
namespace BIMMP.OAMS
{
[Table("OAContractSeal")]
public class OAContractSeal : AuditedEntity<int>
{
[Required]
[MaxLength(50)]
public string ContractName { get; set; }
}
}