Configuring Relationships with Entity Framework Code First

chsakell's Blog

Code First approach allows you to create the Domain Model classes on your own and let Entity Framework do the hard work creating the actual database for you. We have seen in previous post an introduction in Code First development with Entity Framework where we discussed how Code First works by default and how you can interfere to prevent it’s default behavior. We also mentioned that there are three different ways to add your configurations highlighting the one that uses different EntityTypeConfiguration class for each entity, keeping that way the model classes clearer. In this post we will see how to manage relationships between database tables by configuring the domain classes. Moreover, will see:

  1. How Code First manages relationships by default
  2. Which are the options to alter the default behavior
  3. How Cascade works by default
  4. What does Coplex Type mean and how it is used

Let’s start by creating a…

View original post 917 more words