我正在使用ABP模板多页Web应用程序https://aspnetboilerplate.com/Templates 我正在尝试向项目添加带有模型,视图和控制器的新页面。我添加了所有这些文件,并成功迁移到我的数据库中。当我单击链接转到新添加的页面时,出现以下错误
HandlerException:无法创建组件'InvoSuite.EntityFrameworkCore.InvoSuiteDbContext',因为它具有要满足的依赖关系。 'InvoSuite.EntityFrameworkCore.InvoSuiteDbContext'正在等待以下依赖项: -未注册的服务'Microsoft.EntityFrameworkCore.DbContextOptions`1 [[InvoSuite.EntityFrameworkCore.InvoSuiteDbContext,InvoSuite.EntityFrameworkCore,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = null]]。 Castle.MicroKernel.Handlers.DefaultHandler.AssertNotWaitingForDependency()
在我向控制器添加代码之前,页面运行正常
[AbpMvcAuthorize]
public class TimeCardController : InvoSuiteControllerBase
{
InvoSuiteDbContext _Context;
public TimeCardController(InvoSuiteDbContext context)
{
_Context = context;
}
[BindProperty]
public TimeCardModel TimeCard { get; set; }
public List<TimeCardModel> TimeCardList { get; set; }
public IActionResult Index()
{
var data = (from timecardlist in _Context.TimeCardKey
select timecardlist).ToList();
TimeCardList = data;
return View();
}
}
表
[Table("tblTimeCard")]
public class TimeCardModel
{
[Key]
public int TimeCardID { get; set; }
[Required]
public int ContactID { get; set; }
[Required, DisplayFormat(DataFormatString = "{0:d}")]
public DateTime EndOfWeek { get; set; } = DateTime.MinValue;
[DisplayFormat(DataFormatString = "{0:d}")]
public DateTime TimeStamp { get; set; } = DateTime.Now;
public decimal MondayHours { get; set; } = 0;
public decimal TuesdayHours { get; set; } = 0;
public decimal WednesdayHours { get; set; } = 0;
public decimal ThursdayHours { get; set; } = 0;
public decimal FridayHours { get; set; } = 0;
public decimal SaturdayHours { get; set; } = 0;
public decimal SundayHours { get; set; } = 0;
public bool isDeleted { get; set; } = false;
}
这是我的DbContext
public class InvoSuiteDbContext : AbpZeroDbContext<Tenant, Role, User, InvoSuiteDbContext>
{
/* Define a DbSet for each entity of the application */
public DbSet<TimeCardModel> TimeCardKey { get; set; }
public InvoSuiteDbContext(DbContextOptions<InvoSuiteDbContext> options)
: base(options)
{
}
}
不确定是否需要查看我的视图?