Open Closed

Error when adding 1-N navigation property in ABP Suite 8 #6520


User avatar
0
sid@extranerds.com created
  • ABP Framework version: v8.0.0

  • UI Type: Blazor WASM

  • Database System: EF Core (SQL Server)

  • Tiered (for MVC) or Auth Server Separated (for Angular): no

  • Exception message and full stack trace:

  • System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Code\extranerds\AProInspector\test\AProInspector.TestBase\AddressTypes\AddressTypesDataSeedContributor.cs'. at Microsoft.Win32.SafeHandles.SafeFileHandle.CreateFile(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options) at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable1 unixCreateMode) at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable1 unixCreateMode) at System.IO.File.OpenText(String path) at Volo.Abp.IO.FileHelper.ReadAllTextAsync(String path) in D:\ci\Jenkins\workspace\abp-volo-release\abp\framework\src\Volo.Abp.Core\Volo\Abp\IO\FileHelper.cs:line 59 at Volo.Abp.Suite.Areas.AbpSuite.CrudPageGenerator.Commands.UnitTestCommandCommand.mgaozo0CnE(String ) at Volo.Abp.Suite.Areas.AbpSuite.CrudPageGenerator.Commands.UnitTestCommandCommand.LshoDsMRxy(TestDataObject , Int32 ) at Volo.Abp.Suite.Areas.AbpSuite.CrudPageGenerator.Commands.UnitTestCommandCommand.ipuoypI5wn() at Volo.Abp.Suite.Areas.AbpSuite.CrudPageGenerator.Commands.UnitTestCommandCommand.ExecuteAsync(CrudPageCommandOptions options) at Volo.Abp.Suite.Areas.AbpSuite.CrudPageGenerator.CommandManager.ExecuteAllAsync(CrudPageCommandOptions options) at Volo.Abp.Suite.Areas.AbpSuite.CrudPageGenerator.Commands.CrudPageGenerator.GenerateAsync(EntityModel entity, Solution solution, EntityModel masterEntity) at Volo.Abp.Suite.Controllers.CrudPageGeneratorController.SaveAndGenerateEntityAsync(Guid solutionId, EntityModel entity) at lambda_method2022(Closure, Object) at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfActionResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)PS C:\Code\extranerds\AProInspector> Shutting down...

  • Steps to reproduce the issue:

  1. Create a new project
  2. Add a new entity using ABP Suite named "AddressType" (AddressTypes plural)
  3. Add another new entity using ABP Suite named "ClientAddress" (ClientAddresses plural) with a 1-n navigation property referencing AddressTypes
  4. Save and Generate

Notice that the exception is the result of the process trying to locate "AProInspector.TestBase\AddressTypes\AddressTypesDataSeedContributor.cs". However, that file exists elsewhere at "AProInspector.Domain.Tests\AddressTypes\AddressTypesDataSeedContributor.cs".

Please provide a temporary workaround if possible. I'm dealing with a deadline. Thank you.


8 Answer(s)
  • User Avatar
    0
    sid@extranerds.com created

    Here's a screenshot of Visual Studio after ABP Suite generates the error. Note the two areas in the red squares. The file paths don't match.

  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    Hi, thanks for the explanation. We fixed this problem and it will be available with v8.0.2. In meantime, you can uncheck "unit and integration test" checkbox while generating the entity.

  • User Avatar
    0
    sid@extranerds.com created

    Thank you for the response, the info about 8.0.2, and the temporary workaround. Can you tell me which Github issue or pull request the fix relates too?

  • User Avatar
    0
    sid@extranerds.com created

    I have installed CLI and ABP Suite to 8.0.2, and I updated my project's NPM and NuGet packages. After performing this update I compiled the application and tested it. No problems.

    Next I tried to perform the actions that resulted in this ticket being created. I'm sorry to say that the fix mentioned did not solve the problem. Look at the screen shot below. It's slightly different than the one I provided previously (see the areas highlighted with red boxes). In this example, I have an entity called "AddressType" and another entity called "ClientAddress". I am attempting to edit the ClientAddress entity by adding a 1-n navigation property to AddressType.

    Notice that previously (before I upgraded to 8.0.2) this incorrect path was being used, which resulted in the error I initially reported: \test\AProInspector.TestBase\AddressType\AddressTypesDataSeedContributor.cs In other words, it was searching for the correct file in the correct folder of the incorrect project.

    Now, after the 8.0.2 update, the same error occurs but for a different reason. Now, this incorrect path is being used: \test\AProInspector.Domain.Tests\ClientAddresses\AddressTypesDataSeedContributor.cs In other words, it's searching for the correct file in the incorrect folder of the correct project. The folder it's looking is in "ClientAddress", but it should be looking in "AddressTypes". The confusion is probably because "ClientAddress" is the entity I'm currently editing instead of the entity I am trying to create a navigation property link to.

    The correct path should be this. \test\AProInspector.Domain.Tests\AddressType\AddressTypesDataSeedContributor.cs In other words, I think that it should look into the "{ProjectName}.Domain.Tests" project, in the "{ReferencedEntity}" folder for the "{ReferencedEntity}DataSeedContributor.cs" file.

    So it's now looking in the correct project (that was fixed), but now it's look in the incorrect folder (that was broken in the process).

    Please advise.

  • User Avatar
    0
    sid@extranerds.com created

    I actually don't know which file it should be looking for. If it's instead trying to locate the ClientAddressesDataSeedContributor.cs file then it's looking for the incorrect file in the correct folder of the correct project.

    So either the folder name or the file name is incorrect, though I can confirm the project name was fixed.

  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    Hi, it seems it's not looking in the correct directory. I'll recheck it again in the code.

  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    I have updated ABP Suite from the server (for this bugfix), so please follow the below steps:

    1.) Uninstall ABP Suite:

    dotnet tool uninstall -g Volo.Abp.Suite
    

    2.) Clear NuGet caches:

    dotnet nuget locals all --clear
    

    3.) Re-install ABP Suite:

    abp suite install --version 8.0.2
    

    Then, when you regenerate the entity, it should work as expected.

  • User Avatar
    0
    sid@extranerds.com created

    That seems to have fixed the issue. Thank you!

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