Open Closed

Navigating into User Entity from Another Entity #657


User avatar
0
falsharif created

Hi team, Iam Trying to create a navigation property for Appuser from my entity so i can include the name of the creator in the front end : i read the documentation and it said something about maping it or ignoring it , but i dont understand what to do exactly

My entity :

{ public class InventoryAdjustmentLog : AuditedEntityWithUser<Guid,AppUser> {

    public InventoryAdjustmentLog()
    {
        
      
    }

  
   public int CurrentStockLevel { get; set; }

   public int AdjustedStockLevel { get; set; }

   public Guid? ReasonId { get; set; }

   public virtual Reason Reason { get; set; }

    public Guid ProductId { get; set; }

   public virtual Product Product { get; set; }


 

}

}

How can i implement this without getting this error :

---- System.InvalidOperationException : The property 'AppUser.ExtraProperties' could not be mapped, because it is of type 'Dictionary&lt;string, object&gt;' which is not a supported primitive type or a valid entity type. Either explicitly map this property, or ignore it using the '[NotMapped]' attribute or by using 'EntityTypeBuilder.Ignore' in 'OnModelCreating'.

Message: Volo.Abp.AbpInitializationException : An error occurred during ConfigureServices phase of the module Dukkantek.EntityFrameworkCore.DukkantekEntityFrameworkCoreTestModule, Dukkantek.EntityFrameworkCore.Tests, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null. See the inner exception for details. ---- System.InvalidOperationException : The property 'AppUser.ExtraProperties' could not be mapped, because it is of type 'Dictionary<string, object>' which is not a supported primitive type or a valid entity type. Either explicitly map this property, or ignore it using the '[NotMapped]' attribute or by using 'EntityTypeBuilder.Ignore' in 'OnModelCreating'. Stack Trace: AbpApplicationBase.ConfigureServices() AbpApplicationBase.ctor(Type startupModuleType, IServiceCollection services, Action1 optionsAction) AbpApplicationWithExternalServiceProvider.ctor(Type startupModuleType, IServiceCollection services, Action1 optionsAction) AbpApplicationFactory.Create(Type startupModuleType, IServiceCollection services, Action1 optionsAction) AbpApplicationFactory.Create[TStartupModule](IServiceCollection services, Action1 optionsAction) ServiceCollectionApplicationExtensions.AddApplication[TStartupModule](IServiceCollection services, Action1 optionsAction) AbpIntegratedTest1.ctor() DukkantekTestBase1.ctor() DukkantekApplicationTestBase.ctor() InventoryAppServiceTests.ctor(ITestOutputHelper Output) line 23 ----- Inner Stack Trace ----- ModelValidator.ValidatePropertyMapping(IModel model, IDiagnosticsLogger1 logger) ModelValidator.Validate(IModel model, IDiagnosticsLogger1 logger) RelationalModelValidator.Validate(IModel model, IDiagnosticsLogger1 logger) SqliteModelValidator.Validate(IModel model, IDiagnosticsLogger1 logger) ValidatingConvention.ProcessModelFinalized(IConventionModelBuilder modelBuilder, IConventionContext1 context) ImmediateConventionScope.OnModelFinalized(IConventionModelBuilder modelBuilder) ConventionDispatcher.OnModelFinalized(IConventionModelBuilder modelBuilder) Model.FinalizeModel() ModelBuilder.FinalizeModel() ModelSource.CreateModel(DbContext context, IConventionSetBuilder conventionSetBuilder) ModelSource.GetModel(DbContext context, IConventionSetBuilder conventionSetBuilder) DbContextServices.CreateModel() DbContextServices.get_Model() <>c.<TryAddCoreServices>b__7_3(IServiceProvider p) CallSiteRuntimeResolver.VisitFactory(FactoryCallSite factoryCallSite, RuntimeResolverContext context) CallSiteVisitor2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument) CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType) CallSiteRuntimeResolver.VisitScopeCache(ServiceCallSite singletonCallSite, RuntimeResolverContext context) CallSiteVisitor2.VisitCallSite(ServiceCallSite callSite, TArgument argument) CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context) CallSiteVisitor2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument) CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType) CallSiteRuntimeResolver.VisitScopeCache(ServiceCallSite singletonCallSite, RuntimeResolverContext context) CallSiteVisitor2.VisitCallSite(ServiceCallSite callSite, TArgument argument) CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope) <>c__DisplayClass1_0.<RealizeService>b__0(ServiceProviderEngineScope scope) ServiceProviderEngine.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope) ServiceProviderEngineScope.GetService(Type serviceType) ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType) ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider) DbContext.get_DbContextDependencies() DbContext.get_InternalServiceProvider() IServiceProvider>.get_Instance() InfrastructureExtensions.GetService[TService](IInfrastructure1 accessor) AccessorExtensions.GetService[TService](IInfrastructure1 accessor) DukkantekEntityFrameworkCoreTestModule.CreateDatabaseAndGetConnection() line 56 DukkantekEntityFrameworkCoreTestModule.ConfigureInMemorySqlite(IServiceCollection services) line 29 DukkantekEntityFrameworkCoreTestModule.ConfigureServices(ServiceConfigurationContext context) line 25 AbpApplicationBase.ConfigureServices()

  • ABP Framework version: v3.1.2
  • UI type: Angular
  • Tiered (MVC) or Identity Server Seperated (Angular): no
  • Exception message and stack trace:
  • Steps to reproduce the issue:

3 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    We have samples: https://github.com/abpframework/abp-samples/tree/master/DocumentationSamples/CustomApplicationModules may can help you.

  • User Avatar
    0
    falsharif created

    This is not what i am looking for. I tried this and it works when its one to one, but as you can see my relationship is one to many :

    1 user has many InventoryAdjustmentLogs.

    Can you please show me an example that covers this scenario ?

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    HI,

    I have made a samples : https://github.com/realLiangshiwei/Qa657

Made with ❤️ on ABP v9.1.0-preview. Updated on November 11, 2024, 11:11