Base solution for your next web application
Open Closed

Database performance optimization #11971


User avatar
0
niengineering created

We are trying to compile the DbContext to improve the speed in startup of our application.

We are running the command "Optimize-DbContext" on EntityFrameworkCore project and we are receiving the error "The entity type 'Edition' has a query filter configured. Compiled model can't be generated, because query filters are not supported.".

Is there a standard way to bypass this issue in ASPNETZERO?

Thank you


7 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Please check https://stackoverflow.com/questions/70795602/asp-net-boilerplate-v7-x-not-working-with-compiled-models-for-ef-core-6-x. Related EF Core issue is still open, so I guess this is not supported by EF Core at the moment.

  • User Avatar
    0
    niengineering created

    Hi,

    but how and where can I remove the queryfilter from Entity table?

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    We don't suggest removing query filters because it will break many parts of the application. For example, tenants will start to see each others records etc...

    Instead of using Optimize-DbContext, you can find queries on the web to detect performance problems on your database. For example, this one can be used for SQL Server https://blog.sqlauthority.com/2011/01/03/sql-server-2008-missing-index-script-download/

  • User Avatar
    0
    niengineering created

    Thank you for the answer but it is not solving the issue. In our case the problem is the long startup time needed and caused by the big number of tables we have. This is very annoying during development and wasting a lot of time of developers. Can we solve this issue in some other way?

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @niengineering

    Is it possible for you to share the log file where we can see which part takes the longest time during startup ?

  • User Avatar
    0
    niengineering created

    Here the most important part (I can share more privately)

    DEBUG 2024-04-25 22:04:34,428 [1 ] o.Configuration.LanguageManagementConfig - Converted XYZ (Abp.Localization.Dictionaries.DictionaryBasedLocalizationSource) to MultiTenantLocalizationSource DEBUG 2024-04-25 22:04:34,428 [1 ] o.Configuration.LanguageManagementConfig - Converted AbpWeb (Abp.Localization.Dictionaries.DictionaryBasedLocalizationSource) to MultiTenantLocalizationSource DEBUG 2024-04-25 22:04:39,718 [1 ] ameworkCore.AbpEntityFrameworkCoreModule - Registering DbContext: XYZ.EntityFrameworkCore.XYZDbContext, XYZ.EntityFrameworkCore, Version=12.1.0.0, Culture=neutral, PublicKeyToken=null DEBUG 2024-04-25 22:09:03,436 [1 ] Abp.Localization.LocalizationManager - Initializing 4 localization sources. DEBUG 2024-04-25 22:09:03,507 [1 ] Abp.Localization.LocalizationManager - Initialized localization source: Abp

    AS you can see the longest time is taken by "Registering DbContext"

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    This part is executed here https://github.com/aspnetboilerplate/aspnetboilerplate/blob/dev/src/Abp.EntityFrameworkCore/EntityFrameworkCore/AbpEntityFrameworkCoreModule.cs. Maybe you can overwrite this method and try to find the problematic part. You may add additional logs as well.