I have a problem when i try to code with .NET Framework(4.7.2) and EF Core(3.0) because usually i use .NET Core. When i try to inject Repository(by its interface).
This is my code
SenderController.cs
public class SenderController : Controller
{
private readonly ISenderRepository _sRepo;
public SenderController(ISenderRepository sRepo)
{
_sRepo = sRepo;
}
public ActionResult Index()
{
return View();
}
ISenderRepository.cs
public interface ISenderRepository
{
ICollection<Sender> GetSenders();
Sender GetSender(int senderId);
bool SenderExists(string name);
bool SenderExists(int id);
bool CreateSender(Sender sender);
bool UpdateSender(Sender sender);
bool DeleteSender(Sender sender);
bool Save();
}
and this is what i get
i think i do wrong way for dependency injection in MVC 5. Can you help me to do that? Thank you :)
CodePudding user response:
Make sure you have to inject your controller, you can use Autofac to help you
CodePudding user response:
I just fixing it by using this statement in constructor :
private ISenderRepository _sRepo;
public SenderController()
{
this._sRepo = new SenderRepository(new Data.ApplicationDbContext());
}
Thanks