Using EF7 beta7, a new set of methods is introduced to determine the relationships between objects.
For relationships from one to several,
modelBuilder.Entity<Post>() .Reference(typeof(Blog), "Blog") .InverseCollection("Posts") .ForeignKey(new string[] { "BlogId" });
With .Reference(typeof(Blog), "Blog") settings .Reference(typeof(Blog), "Blog") from Entity Post to Blog . The first argument is the type of object that will set the goals, and the second argument is the name of the navigation property.
Using .InverseCollection("Posts") , a one-to-many relationship is configured. The argument to this function is the name of the navigation collection.
Using .ForeignKey(new string[] { "BlogId" }) foreign key is configured. If this foreign key is not installed, a shadow foreign key is automatically generated for you.
source share