ASP.NET MVC using DbSet with database using dot notation -




i trying implement worldwideimporters sample database in asp.net mvc application.

everything working using test sql database single table "persons".

however when using worldwideimporters every table sorted categories: application.cities , application.countries or sales.orders , sales.customers.

where write model this:

public class datacontext : dbcontext     {         public datacontext(dbcontextoptions<datacontext> options) : base(options)         { }          public dbset<person> persons { get; set; }     }      public class person     {         [key]         public int personid { get; set; }         [required]         public string firstname { get; set; }     } 

and controller this:

 public class peronscontroller : controller     {         private readonly datacontext _context;          public peronscontroller(datacontext context)         {             _context = context;         }          // get: orders         public async task<iactionresult> index()         {             return view(await _context.persons.tolistasync());         }     } 

i no longer able when database tables sorted dot instance sales.orders not work in above model , controllers. how can correctly model , controller sample database?

this do:

public class shopcontext : dbcontext {     public shopcontext(dbcontextoptions<shopcontext> options) : base(options)     { }      public dbset<city> application.cities { get; set; } }  public class city {     [key]     public int cityid { get; set; }     [required]     public string cityname { get; set; } } 

these prefixes before dot called schema

there few references explaining can do;

[table("customers", schema = "ordering")]        

and still call table it's name (without part preceding dot)

http://devproconnections.com/entity-framework/working-schema-names-entity-framework-code-first-design

entity framework , multiple schemas





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -