You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: entity-framework/core/modeling/data-seeding.md
-3
Original file line number
Diff line number
Diff line change
@@ -18,9 +18,6 @@ There are several ways this can be accomplished in EF Core:
18
18
19
19
## Model seed data
20
20
21
-
> [!NOTE]
22
-
> This feature is new in EF Core 2.1.
23
-
24
21
Unlike in EF6, in EF Core, seeding data can be associated with an entity type as part of the model configuration. Then EF Core [migrations](xref:core/managing-schemas/migrations/index) can automatically compute what insert, update or delete operations need to be applied when upgrading the database to a new version of the model.
Copy file name to clipboardExpand all lines: entity-framework/core/modeling/relationships.md
+50-1
Original file line number
Diff line number
Diff line change
@@ -267,6 +267,55 @@ With this configuration the columns corresponding to `ShippingAddress` will be m
267
267
268
268
### Many-to-many
269
269
270
-
Many-to-many relationships without an entity class to represent the join table are not yet supported. However, you can represent a many-to-many relationship by including an entity class for the join table and mapping two separate one-to-many relationships.
270
+
Many to many relationships require a collection navigation property on both sides. They will be discovered by convention like other types of relationships.
The way this relationship is implemented in the database is by a join table that contains foreign keys to both `Post` and `Tag`. For example this is what EF will create in a relational database for the above model.
Internally, EF creates an entity type to represent the join table that will be referred to as the join entity type. There is no specific CLR type that can be used for this, so `Dictionary<string, object>` is used. More than one many-to-many relationships can exist in the model, therefore the join entity type must be given a unique name, in this case `PostTag`. The feature that allows this is called shared-type entity type.
299
+
300
+
The many to many navigations are called skip navigations as they effectively skip over the join entity type. If you are employing bulk configuration all skip navigations can be obtained from `GetSkipNavigations`.
[Model seed data](xref:core/modeling/data-seeding) can be provided for the join entity type by using anonymous types. You can examine the model debug view to determine the property names created by convention.
Additional data can be stored in the join entity type, but for this it's best to create a bespoke CLR type. When configuring the relationship with a custom join entity type both foreign keys need to be specified explicitly.
0 commit comments