No foreign key property

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 ...

Get Mastering Entity Framework Core 2.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.