events.action: opened
events.author: mahmoudkandeel
events.masked_author: username_0
events.text: ![image](https://user-images.githubusercontent.com/3681500/61166426-6c43ba00-a52d-11e9-89c6-d71a8ac8557a.png)
events.title: OnModelCreating Unable to determine the relationship represented by navigation property 'User.DeleterUser'
events.type: issue
events.action: created
events.author: ismcagdas
events.masked_author: username_1
events.text: @username_0 have you called `base.OnModelCreating()` as the first line of your OnModelCreating method ?
events.type: comment
events.action: closed
events.author: mahmoudkandeel
events.masked_author: username_0
events.type: issue
events.action: created
events.author: mahmoudkandeel
events.masked_author: username_0
events.text: thanks it works
events.type: comment
events.action: created
events.author: metaphysys
events.masked_author: username_2
events.text: what if it doesn't work even adding it? i have used "aspnet zero - create entity" and this is the state:
  
  ```
  public class PPlusDbContext : AbpDbContext
      {
  
          public virtual DbSet<UserOrganization> UserOrganizations { get; set; }
  
          public virtual DbSet<Organization> Organizations { get; set; }
  
          public virtual DbSet<OwnerUserOrganization> OwnerUserOrganizations { get; set; }
          
          public virtual DbSet<ProfileOrganization> ProfileOrganizations { get; set; }
  
          public virtual DbSet<RoleProfile> RoleProfiles { get; set; }
  
          public virtual DbSet<Profile> Profiles { get; set; }
  
          public virtual DbSet<PlanGrouping> PlanGroupings { get; set; }
  
          public virtual DbSet<PlantGroup> PlantGroups { get; set; }
  
          public virtual DbSet<Plant> Plants { get; set; }
  
          public virtual DbSet<UserGrouping> UserGroupings { get; set; }
  
          public virtual DbSet<UserGroup> UserGroups { get; set; }
  
          public virtual DbSet<ApplicationGroupOrganization> ApplicationGroupOrganizations { get; set; }
  
          public virtual DbSet<ApplicationModule> ApplicationModules { get; set; }
  
          public virtual DbSet<ApplicationGrouping> ApplicationGroupings { get; set; }
  
          public virtual DbSet<ApplicationGroup> ApplicationGroups { get; set; }
  
          public virtual DbSet<Application> Applications { get; set; }
  
          public virtual DbSet<Module> Modules { get; set; }
          
          public PPlusDbContext(DbContextOptions<PPlusDbContext> options) 
              : base(options)
          {
              
          }
  
           protected override void OnModelCreating(ModelBuilder modelBuilder)
          {
              base.OnModelCreating(modelBuilder);
  
               modelBuilder.Entity<ApplicationGroupOrganization>(a =>
              {
                  a.HasIndex(e => new { e.TenantId });
              });
              modelBuilder.Entity<ApplicationModule>(a =>
              {
                  a.HasIndex(e => new { e.TenantId });
              });
              modelBuilder.Entity<ApplicationGrouping>(a =>
              {
                  a.HasIndex(e => new { e.TenantId });
              });
              modelBuilder.Entity<ApplicationGroup>(a =>
              {
                  a.HasIndex(e => new { e.TenantId });
              });
              modelBuilder.Entity<Application>(a =>
              {
                  a.HasIndex(e => new { e.TenantId });
              });
              modelBuilder.Entity<Module>(m =>
              {
                  m.HasIndex(e => new { e.TenantId });
              });
              modelBuilder.Entity<ProfileOrganization>(p =>
              {
                  p.HasIndex(e => new { e.TenantId });
              });
              modelBuilder.Entity<RoleProfile>(r =>
              {
                  r.HasIndex(e => new { e.TenantId });
              });
              modelBuilder.Entity<Profile>(p =>
              {
                  p.HasIndex(e => new { e.TenantId });
              });
              modelBuilder.Entity<PlanGrouping>(p =>
              {
                  p.HasIndex(e => new { e.TenantId });
              });
              modelBuilder.Entity<PlantGroup>(p =>
              {
                  p.HasIndex(e => new { e.TenantId });
              });
              modelBuilder.Entity<Plant>(p =>
              {
                  p.HasIndex(e => new { e.TenantId });
              });
              modelBuilder.Entity<UserGrouping>(u =>
              {
                  u.HasIndex(e => new { e.TenantId });
              });
              modelBuilder.Entity<UserGroup>(u =>
              {
                  u.HasIndex(e => new { e.TenantId });
              });
              modelBuilder.Entity<OwnerUserOrganization>(o =>
              {
                  o.HasIndex(e => new { e.TenantId });
              });
              modelBuilder.Entity<UserOrganization>(u =>
              {
                  u.HasIndex(e => new { e.TenantId });
              });
              modelBuilder.Entity<Organization>(o =>
              {
                  o.HasIndex(e => new { e.TenantId });
              });
  
              modelBuilder.ConfigurePersistedGrantEntity();
  
          }
  }
  ```
  
  i get the same error, apparently from a relationship to the native user table.
  
  ```
  PM> add-migration FirstMigration
  Build started...
  Build succeeded.
  System.InvalidOperationException: Unable to determine the relationship represented by navigation property 'User.DeleterUser' of type 'User'. Either manually configure the relationship, or ignore this property using the '[NotMapped]' attribute or by using 'EntityTypeBuilder.Ignore' in 'OnModelCreating'.
     at Microsoft.EntityFrameworkCore.Infrastructure.ModelValidator.ValidatePropertyMapping(IModel model, IDiagnosticsLogger`1 logger)
     at Microsoft.EntityFrameworkCore.Infrastructure.ModelValidator.Validate(IModel model, IDiagnosticsLogger`1 logger)
     at Microsoft.EntityFrameworkCore.Infrastructure.RelationalModelValidator.Validate(IModel model, IDiagnosticsLogger`1 logger)
     at Pomelo.EntityFrameworkCore.MySql.Internal.MySqlModelValidator.Validate(IModel model, IDiagnosticsLogger`1 logger)
     at Microsoft.EntityFrameworkCore.Metadata.Conventions.ValidatingConvention.ProcessModelFinalized(IConventionModelBuilder modelBuilder, IConventionContext`1 context)
     at Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.ConventionDispatcher.ImmediateConventionScope.OnModelFinalized(IConventionModelBuilder modelBuilder)
     at Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.ConventionDispatcher.OnModelFinalized(IConventionModelBuilder modelBuilder)
     at Microsoft.EntityFrameworkCore.Metadata.Internal.Model.FinalizeModel()
     at Microsoft.EntityFrameworkCore.ModelBuilder.FinalizeModel()
     at Microsoft.EntityFrameworkCore.Infrastructure.ModelSource.CreateModel(DbContext context, IConventionSetBuilder conventionSetBuilder)
     at Microsoft.EntityFrameworkCore.Infrastructure.ModelSource.GetModel(DbContext context, IConventionSetBuilder conventionSetBuilder)
     at Microsoft.EntityFrameworkCore.Internal.DbContextServices.CreateModel()
     at Microsoft.EntityFrameworkCore.Internal.DbContextServices.get_Model()
     at Microsoft.EntityFrameworkCore.Infrastructure.EntityFrameworkServicesBuilder.<>c.<TryAddCoreServices>b__7_3(IServiceProvider p)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactory(FactoryCallSite factoryCallSite, RuntimeResolverContext context)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScopeCache(ServiceCallSite singletonCallSite, RuntimeResolverContext context)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScopeCache(ServiceCallSite singletonCallSite, RuntimeResolverContext context)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine.<>c__DisplayClass1_0.<RealizeService>b__0(ServiceProviderEngineScope scope)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
     at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType)
     at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
     at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
     at Microsoft.EntityFrameworkCore.DbContext.get_DbContextDependencies()
     at Microsoft.EntityFrameworkCore.DbContext.get_InternalServiceProvider()
     at Microsoft.EntityFrameworkCore.DbContext.Microsoft.EntityFrameworkCore.Infrastructure.IInfrastructure<System.IServiceProvider>.get_Instance()
     at Microsoft.EntityFrameworkCore.Infrastructure.Internal.InfrastructureExtensions.GetService[TService](IInfrastructure`1 accessor)
     at Microsoft.EntityFrameworkCore.Infrastructure.AccessorExtensions.GetService[TService](IInfrastructure`1 accessor)
     at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.CreateContext(Func`1 factory)
     at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.CreateContext(String contextType)
     at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.AddMigration(String name, String outputDir, String contextType)
     at Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigrationImpl(String name, String outputDir, String contextType)
     at Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigration.<>c__DisplayClass0_0.<.ctor>b__0()
     at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass3_0`1.<Execute>b__0()
     at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
  Unable to determine the relationship represented by navigation property 'User.DeleterUser' of type 'User'. Either manually configure the relationship, or ignore this property using the '[NotMapped]' attribute or by using 'EntityTypeBuilder.Ignore' in 'OnModelCreating'.
  ```
  
  This is the entity, relation n:m between my table `organizations` and the native table `users`:
  
  ```
  [Table("ProUserOrganizations")]
      public class UserOrganization : FullAuditedEntity<long> , IMayHaveTenant
      {
  			public int? TenantId { get; set; }
  			
  
  
  		public virtual long UserId { get; set; }
  		
          [ForeignKey("UserId")]
  		public User UserFk { get; set; }
  		
  		public virtual long OrganizationId { get; set; }
  		
          [ForeignKey("OrganizationId")]
  		public Organization OrganizationFk { get; set; }
  		
      }
  ```
events.type: comment
events.action: created
events.author: maliming
events.masked_author: username_3
events.text: `User.DeleterUser` means you are using the function of abp zero(), please use **AbpZeroDbContext**(https://github.com/aspnetboilerplate/aspnetboilerplate/blob/master/src/Abp.ZeroCore.EntityFrameworkCore/Zero/EntityFrameworkCore/AbpZeroDbContext.cs).
events.type: comment