Reputation: 1167
When adding a new view to an ASP.NET MVC 5 project using the Add View dialog pictured below, I'm invited to choose a template and a model class, which allows me to quickly generate a form for creating new instances of the model or a view that displays the model's properties. But why should the view care what the data context class is? In my project, whether or not I specify the data context class, the same view is generated, but I'm guessing there's a scenario where it would make a difference. What might that be?
Upvotes: 12
Views: 5618
Reputation: 2675
If you refer to an existing DbContext then the wizard will insert public DbSet<Employee> Employee { get; set; }
(if it doesn't already exist) in your DbContext derived class . Looks like Visual Studio doing some of the leg work.
Upvotes: 7