We have a huge database with 770 tables and we want to conduct performance testing using EF 6.1x.
We want to query only 5 of these 770 tables. Is it possible to create a “lightweight” DBC text with 5-6 entities / DBSets instead of using the full 770-tables context?
When we use the full context, a simple request with 4 connections takes 45 seconds. It is 44 seconds too long. We use the first code (reverse design).
Problem: When we create such an “easy” version of the full context (i.e., Only 5 tables), EF complains that all other objects that are somehow related to these 5 tables have missing keys. We display only keys, properties, relationships for these 5 tables, but not the rest.
Since a query written in LINQ only requests 5 tables, EF should just ignore the remaining 765 tables, but it will not. Why not? LazyLoading = true / false does not seem to have anything to do with this.
Note. Obviously, you can create a database view that does what we do in the LINQ query code. The question is whether this can be done using the "light" DbContext, as described above.
There is a light version of the context:
public class ItemLookupContext : DbContext { static ItemLookupContext() { Database.SetInitializer<ItemLookupContext>( null ); } public ItemLookupContext() : base( "Name=ItemLookupContext" ) { //Configuration.LazyLoadingEnabled = true; } public DbSet<Identity> Identities { get; set; } public DbSet<Item> Items { get; set; } public DbSet<Price> Prices { get; set; } public DbSet<Department> Departments { get; set; } public DbSet<Brand> Brands { get; set; } protected override void OnModelCreating( DbModelBuilder modelBuilder ) { modelBuilder.Configurations.Add( new IdentityMap() ); modelBuilder.Configurations.Add( new ItemMap() ); modelBuilder.Configurations.Add( new PriceMap() ); modelBuilder.Configurations.Add( new DepartmentMap() ); modelBuilder.Configurations.Add( new BrandMap() ); //ignore certain entitities to speed up loading? //does not work modelBuilder.Ignore<...>(); modelBuilder.Ignore<...>(); modelBuilder.Ignore<...>(); modelBuilder.Ignore<...>(); modelBuilder.Ignore<...>(); } }
source share