Reputation: 1017
New to EF. Following along with DBContext by Lerman/Miller.
When I start a new project, adding EF6 (Database First), the DBContext seems to be added as a default (ie I don't have to add the DBContext separately with T4). Also, for Lazy Loading, the "virtual" needed in the class definitions also seems to be there by default (I don't have to add it like in the book). Is this what is expected?
Upvotes: 1
Views: 43
Reputation: 8171
When you use Database First
approach and use EF x DbContext Generator
it creates the DbContext
for you automatically and set the navigation properties, virtual
. If you want to disable lazy loading
you can simply use following code
public class MyContext : DbContext
{
public MyContext()
{
this.Configuration.LazyLoadingEnabled = false;
}
}
Upvotes: 1
Reputation: 6607
Most probably the books you are reading are for code first development. If you use database first(especially with the designer) you don't need to make changes.
Upvotes: 0