I have the Database Specification for the application, that was created previously for iOS, and which used Apple Core Data as an ORM, so that all the relationships between tables there are bidirectional.
Do I need to do the same in Entity Framework (bidirectional relationships, which in most case are impossible to implement), or may I just use typical (One-to-One, Many-to-One, Many-to-Many) relationships and they will work the same way as bidirectional in Apple Core Data?
You make a mistake in you reasoning. You confuse the database configuration with the ORM configuration. When there is a one to many relation between a parent and a child table, the child table will hold a foreign key to the parent table. The parent table wil not have any field that relates to the child table.
When defining this relation using Code First you are free to implement it as:
Public Class Parent
Public Property Id as Integer
Public Overridable Property Children as ICollection(Of Child)
End Class
Public Class Child
Public Property Id as Integer
Public Property ParentId as Integer
Public Overridable Property Parent as Parent
End Class
Or
Public Class Parent
Public Property Id as Integer
End Class
Public Class Child
Public Property Id as Integer
Public Property ParentId as Integer
Public Overridable Property Parent as Parent
End Class
Or
Public Class Parent
Public Property Id as Integer
Public Overridable Property Children as ICollection(Of Child)
End Class
Public Class Child
Public Property Id as Integer
Public Property ParentId as Integer
End Class
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.