![]() To jump into examples for different kinds of relationships, see: Find out moreĮF supports many different types of relationships, with many different ways these relationships can be represented and configured. ![]() Now all these properties will behave coherently together as a representation of a single relationship between Blog and Post. For example: protected override void OnModelCreating(ModelBuilder modelBuilder) This is done automatically by EF when building a simple relationship like this, but can also be specified explicitly when overriding the OnModelCreating method of your DbContext. The primary key property of Blog, Blog.Id, and the foreign key property of Post, Post.BlogId, can then be associated with the references ("navigations") between the entity types ( Blog.Posts and Post.Blog). However, even when the properties are hidden, it is important to recognize that they still exist in the EF model. Primary and foreign key properties don't need to be publicly visible properties of the entity type. Once this mapping is made, EF changes the foreign key values as needed when the references between objects change, and changes the references between objects as needed when the foreign key values change.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |