1
Hello, I have a question related to the Dbcontext instantiation mode in the controller. What is the difference between the two methods below instantiation ?
1.
private ApplicationDbContext _db;
public ApplicationDbContext db
{
get { return _db ?? new ApplicationDbContext(); }
set { _db = value; }
}
2.
private readonly ApplicationDbContext db = new ApplicationDbContext();
Because currently I use the second, but in several models of ASP.NET MVC 5 I see that comes as standard the first option...
In fact if you instance like this is already wrong the two ways ... !!! in the functional sense the two work the same way and brings what you need.
– novic