Starting with Code First in Entity Framework

chsakell's Blog

Code First is probably the most preferred way to build an Entity Data Model that can be used with Entity Framework to perform data access. Database First and Model First are the also quite important but less used. In Code First modeling, you define your domain classes and mapping in.. code (yeap this is where it’s name comes from). You need to know that Code First is all about conventions and configurations. For example, it assumes that each of your domain classes have a key property otherwise you will get an exception. If a property on a domain class ends with “Id” it is going to be treated as a key property automatically, otherwise you will have to annotate at least on property with the [Key] annotation. We ‘ll skip the theory and will go straight forward to practice. In this post we will see how to use Code First…

View original post 1,229 more words