We usually create entities using fully-defined relationships, but this is not expected by Entity Framework. In a relationship, the foreign key is not required, but it is recommended to have one:
The following code does not contain foreign key in the Post entity and still the relationship is formed:
public class Blog { // code removed for brevity public ICollection<Post> Posts { get; set; } } public class Post { // code removed for brevity // Foreign key BlogId was removed from here public Blog Blog { get; set; } }
The following image illustrates that without foreign key, the relationship is built:
We have removed ...