I am trying my hands on creating an ASP.NET MVC 5 app without entity framework.
I have some existing database, but do not want to use Entity Framework for that. Came up with simple and uncluttered architecture having Entities, Repository and DAL.
I have created a controller passing Repository context to it.
public class EmployeeController : Controller
private readonly IEmployeeRespository repository;
public EmployeeController(IEmployeeRespository _repository)
repository = _repository;
// GET: Employee
public ActionResult Index()
IEnumerable<Employee> Employees = repository.GetEmployees();
Dependency injection is your answer. there are some libraries that will do it for you. You can also do
poor-mans injection yourself, or with a service locator.
You can use autofac or ninject that will orchestrate your dependency resolution.
This would help: How do I properly register AutoFac in a basic MVC5.1 website?