asp.net mvc - Correct way to inject DbContext into a controller -


if wish inject dbcontext 1 of controllers follows:

public class homecontroller : controller {     mydbcontext _db;      public homecontroller(mydbcontext db)     {         _db = db;     }      ... } 

what correct way configure unity. context have intantiated per request perrequestlifetimemanager seems natural choice. reading this documentation seems perrequestlifetimemanager advised against. terms "thread-unsafe dependencies" make me nervous using warning causing "bugs in end user’s application code". warnings seem vague though not clear dangers are. can give examples of kind of bugs can occur use of perrequestlifetimemanager? , if lifetime manager advised against, better way inject dbcontext controllers?


Comments