Open Closed

Master Detail doesn't work #6436


User avatar
0
nabass created

it doesn't work with me despite i made exactly like documentation....when i make a master it completed good but child it gives me a lot of errors while migration 1- says (Error occurred on DB migration step! Make sure the project is compiled and working. Command output: Build started... Build failed. Use dotnet build to see the errors.) 2- when open the code i found property [ public Guid OrderId ] twice ???? why ???? 3- In folder orderDbSet it gives me an error with namespace

  • ABP Framework version: 8.0.0
  • UI Type: MVC
  • Database System: EF Core (SQL Server)
  • Exception message and full stack trace:

3 Answer(s)
  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    Hi, it seems you have added OrderId as either as a property or to establish a one-to-many relationship with the Order entity in your child entity (OrderLine in this example). You don't need to establish one to many relationships, the master-child relationship is enough for the relation, otherwise, it's normal to see OrderId as duplicated.

    | OrderLine.cs | OrderLineDto.cs | | --- | --- | | | |


    So, your OrderLine entity definition should be as follows:

    If you want you can establish one-to-many relationship with other entities, but not with the master entity.

  • User Avatar
    0
    nabass created

    Thank you it works perfectly but i have another question if the child and master is enough why do you put (Navigation tab and 1-n relation)??

  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    Thank you it works perfectly but i have another question if the child and master is enough why do you put (Navigation tab and 1-n relation)??

    You can establish a relationship with another entity (except the master entity itself). For example, you can have Order, OrderLine, and Product entities and want to establish a one-to-many relationship between OrderLine and Product (OrderLine can have multiple products). In this case, it's useful and needed for your use case.

    I close the question since your question is answered. Please create a new ticket, if you have further questions. Best regards.

Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11