asp.net web api - where to put Entity Framework configuration strings in a WebAPI application -


i have started webapi application using vs empty application template. first, have added webapi service functionality - no issues. now, need add entity framework functionality, , i'm facing following issue: not have app.config file in application. can put database configuration parameters such "data source=", "defaultconnectionfactory", etc...? currently, applicationdbcontext file looks this:

using system; using system.collections.generic; using system.data.entity; using system.linq; using system.text; using system.threading.tasks;  namespace webapiservice.models {     public class applicationdbcontext : dbcontext     {         public applicationdbcontext()             : base("dctooldb")         {          }          public idbset<site> sites { get; set; }         public dbset<quote> quotes { get; set; }     }      public class applicationdbinitializer : dropcreatedatabasealways<applicationdbcontext>     {         protected override void seed(applicationdbcontext context)         {             base.seed(context);          }     } } 

to give more exact answer question: have include configuration file (app.config or web.config) in project executed, , not in other class library project. if configuration file doesn't exist, create one. can in vs adding new item of type "configuration file" in chosen project. create web.config file or app.config depending on kind of project.

what "the project executed" mean?

when it's desktop application or web site, it's clear. but, if have test project, executable project qhen run tests. so, if have example web application 2 different test projects, need 3 config files:

  • web.config in web app project, sill used when running app
  • one app.config each test project, used when run corresponding tests

this interesting, beacuse allows keep different configurations each project.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -