I am using the code first approach with a local database (localdb\11.0v) in ASP MVC 4. I have created my entity
public class Service
{
public int ServiceID { get; set; }
public string ServiceName { get; set; }
}
My DbContext
public class EFDbContext : DbContext
{
public DbSet<Service> Service { get; set; }
}
My repositories
public interface IServiceRepository
{
IQueryable<Service> Service { get; }
}
Interface
public class EFServiceRepository : IServiceRepository
{
private EFDbContext context = new EFDbContext();
public IQueryable<Service> Service
{
get { return context.Service; }
}
}
I am using Ninject for the binding
ninjectKernel.Bind<IServiceRepository>().To<EFServiceRepository>();
With the controller referencing the ninject kernel bind
public ActionResult List()
{
return View(repo.Service);
}
So this all works which is good but it does not work the way that i want it to. It pulls a list from the table "Services" but i want it to pull data from the table "Service". I dont understand why this is happening. I did have the var names plural so they were "Services" but that should not make a difference ( should it? ) I changed them all to "Service" in hope that would solve it. I really feel like i was understanding all this until now.
We have "business" rules for the db and they need to be singular names + i really want to understand why it is using the "Services" table and not the "Service" table. I only added the "Services" table to test.