Foreign key between aggregate roots

I understand the concept of an aggregate root, and I know that one aggregate root must refer to another by identity ( http://dddcommunity.org/wp-content/uploads/files/pdf_articles/Vernon_2011_2.pdf ), so I don't get - how can I get the Entity Framework to add a foreign key constraint between two aggregates?

Suppose I have a simplified scope:

public class AggregateOne{
    [Key]
    public Guid AggregateOneID{ get; private set;}
    public Guid AggregateTwoFK{get; private set;}
    /*Other Properties and methods*/
}

public class AggregateTwo{
    [Key]
    public Guid AggregateTwoID{get; private set;}
    /*Other Properties and methods*/
}

With this domain design, the Entity Framework does not know that there is a relationship between AggregateOne and AggregateTwo, and therefore there is no foreign key in the generated database.

+4
source share
2 answers

DDD EF . . EF , . , , DDD, db, DDD. EF (AR).

AR , . EF db , . - , , ( EF , . , ). AR , , . AR , , . ( ).

/ , , , "", - .

DDD , , , DDD, , DDD. IMO CQRS DDD, .

, , , ( !!!), , ( , , , - , , , , ?), , , , , DDD.

- , ( ), . : D . , - , , , , .

+5

? ? , , .

- EF - , . , AggregateOneId AggregateTwoFk AggregateOne. , EF AggregateOne, AggregateTwo, ( , AggregateOne , EF , , AggregateOne.

0

All Articles