There is no argument given that corresponds to the required formal parameter 'context of GenericRepository<Incident>.GenericRepository(dbContext)

十年热恋 提交于 2019-12-03 10:06:13

The error tells you that you don't call an appropriate base constructor. The constructor in the derived class ...

public IncidentRepository(db_SLee_FYPContext context)
{
    this.context = context;
}

... is in fact doing this:

public IncidentRepository(db_SLee_FYPContext context)
    : base()
{
    this.context = context;
}

But there is no parameterless base constructor.

You should fix this by calling the matching base constructor:

public IncidentRepository(db_SLee_FYPContext context)
    : base(context)
{ }

In C# 6 you get this message if there is only one constructor in the base type, so it gives you the best possible hint which argument in the base constructor is missing. In C# 5 the message would simply be

GenericRepository does not contain a constructor that takes 0 arguments

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!