What is the equivalent of .Configuration in Entity Framework Core? Receiving error below
Code Examples:
List<DocumentStatus> documentStatuses;
using (var db = new ModelDBContext())
{
db.Configuration.ProxyCreationEnabled = false;
documentStatuses = db.DocumentStatus.ToList();
}
using (var db = new ModelDBContext())
{
db.Configuration.ProxyCreationEnabled = false;
//Expression<Func<Owner, bool>> predicate = query => true;
db.Configuration.ProxyCreationEnabled
Error Messages throughout:
Error CS1061 'ModelDBContext' does not contain a definition for 'Configuration' and no accessible extension method 'Configuration' accepting a first argument of type 'ModelDBContext' could be found (are you missing a using directive or an assembly reference?)
Based on Entity Framework Core docs: https://docs.microsoft.com/en-us/ef/core/querying/related-data, from EF Core 2.1, there is a way to enable Lazy Loading with or without proxy.
1. Lazy Loading with Proxy:
a. Make sure your navigation property are defined as "virtual"
b. Install the Microsoft.EntityFrameworkCore.Proxies package
c. Enable it with a call to UseLazyLoadingProxies
Or enable it when using AddDbContext
2. Lazy Loading without Proxy:
a. Injecting the ILazyLoader service into an entity, as described in Entity Type Constructors. For example:
By default, EF Core won't use lazy load with proxy, but if you want to use proxy, please follow 1st approach.