0

I am fresh in DDD, and i faced with next issue. I have value object

public record Operation(string Name, string Value);

and two aggregate roots which have this operation in one context

public record Doctor(string Name, Operation Operation);
public record Application (string Name, Operation Operation);

I mapped it

doctorBuilder
            .OwnsOne(x => x.Operation, operationBuilder =>
            {
               .....
            });

application Builder
            .OwnsOne(x => x.Operation, operationBuilder =>
            {
               .....
            });

And get this error Cannot use table 'customer.Operations' for entity type 'Doctor' since it is being used for entity type 'Application' and potentially other entity types, but there is no linking relationship. Add a foreign key to 'Application' on the primary key properties and pointing to the primary key on another entity type mapped to 'customer.Operations'.

How i can map it? Indicate the relationship as one to one does not fit.

Pal
  • 1
  • Side note: it looks very fancy to use records, but it is totally at odds with EF's core features like change tracking and identity resolution. EF's class model is not a domain model and shouldn't be forced into behaving like it. See https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/record#value-equality – Gert Arnold May 30 '23 at 14:41
  • This is an Entity Framework question. From a DDD point of view, the solution is to not do that, because two aggregates cannot share an entity by definition. – Francesc Castells Jul 09 '23 at 08:17

0 Answers0