Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

A filter may only be applied to the root entity type #4176


User avatar
0
indiaict created

Hi, I am using the lastest 3.1.2 ABP with .Net core 2.0. Need some urgent help needed.

I am getting this error while adding the migration from the console - The filter expression 'Param_0 => ((Not(Convert(Param_0, ISoftDelete).IsDeleted) OrElse (Convert(Param_0, ISoftDelete).IsDeleted != value(X.Y.EntityFrameworkCore.DbContext).IsSoftDeleteFilterEnabled)) AndAlso ((Convert(Param_0, IMayHaveTenant).TenantId == value(X.Y.EntityFrameworkCore.DbContext).CurrentTenantId) OrElse ((Convert(Param_0, IMayHaveTenant).TenantId == value(X.Y.EntityFrameworkCore.DbContext).CurrentTenantId) == value(X.Y.EntityFrameworkCore.DbContext).IsMayHaveTenantFilterEnabled)))' cannot be specified for entity type 'Role'. A filter may only be applied to the root entity type in a hierarchy.


7 Answer(s)
  • User Avatar
    0
    alirizaadiyahsi created

    Hi @indiaict

    what change did you do? Could you share some code that is different from original?

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    This is a restriction of EF Core Query Filters, <a class="postlink" href="https://docs.microsoft.com/en-us/ef/core/what-is-new/">https://docs.microsoft.com/en-us/ef/core/what-is-new/</a> see limitations under Model-level query filters.

    According to this, you shouldn't use IMayHaveTenant and IMustHaveTenant for your child entities. As @alirizaadiyahsi said, probably this is caused by a recent change in your project, can you cehck that ? Did you add Role entity to another entity recently ?

  • User Avatar
    0
    indiaict created

    Hi Guys, Thanks for the reply but atleast for the role entitiy we have not put anything. It just derives from AbpRole

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @indiaict,

    I think I coulnd't explain the case very well, sorry for that.

    Do you have a usage like this.

    public class MyEntity{
        ...
        public Role MyFirstRole {get; set;}
        ...
    }
    

    If you don't have such a usage, is it possible for you to send your project to us via email ? If not, we will try to find another way to help you.

  • User Avatar
    0
    indiaict created

    Sorry i have checked but i could not find such entity usage for Role, how can i find ? I cannot share the code :(

  • User Avatar
    0
    indiaict created

    Hi, Any suggestions ?

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @indiaict,

    Do you have any custom role entity which is derived from Role entity ? If not, can you share full stack trace of error message ?

    But, it is hard for us to help you only with this information.