-
Notifications
You must be signed in to change notification settings - Fork 2
hasmany mapping
Todd Thomson edited this page Aug 17, 2018
·
4 revisions
To configure a 1-Many relationship on an entity property use the HasMany() method.
entity.HasMany( p => p.Orders )
.WithForeignKey<Order>( p => p.CustomerId )
.References<Customer>( p => p.Id );
In the above example:
- The .HasMany() lambda expression specifies the entity relationship property.
- The .WithForeignKey<TFKEntity>() lambda expression specifies the entity foreign key property.
- The .References<TRefEntity>() lambda expression specifies the foreign key reference entity and (usually) primary key.