Modeling Self-Reference Relationship Notes with Code First

Original link

1.Has method:

A.HasRequired(a => a.B);
  1. HasOptional: The former contains an instance of the latter or is null
  2. HasRequired: The former (A) contains an instance of the latter (B) that is not null
  3. HasMany: The former contains a collection of instances of the latter

Two.With method:

A.HasRequired(a => a.B);
  1. WithOptional: The latter (B) can contain an instance of the former (A) or null
  2. WithRequired: The latter contains a non-null instance of the former
  3. WithMany: The latter contains a collection of instances of the former

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324692485&siteId=291194637