asp.net mvc - Entity framework ASP MVC 4, Referencing the wrong table -


i using code first approach local database (localdb\11.0v) in asp mvc 4. have created 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         {             { return context.service; }         }     } 

i using ninject binding

 ninjectkernel.bind<iservicerepository>().to<efservicerepository>(); 

with controller referencing ninject kernel bind

public actionresult list()         {             return view(repo.service);         } 

so works not work way want to. pulls list table "services" want pull data table "service". dont understand why happening. did have var names plural "services" should not make difference ( should it? ) changed them "service" in hope solve it. feel understanding until now.

we have "business" rules db , need singular names + want understand why using "services" table , not "service" table. added "services" table test.

first need add code "using" blocks of efdbcontext class:

using system.data.entity.modelconfiguration.conventions 

then add code efdbcontext class:

protected override void onmodelcreating(dbmodelbuilder modelbuilder) {         modelbuilder.conventions.remove<pluralizingtablenameconvention>(); } 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -