Code-Only best practices

There have been lots of posts on the EFDesign blog talking about how the features in Code Only have evolved. But very little covering what we think will be the best way to write the code. You may have seen code like this: var prodConf = builder.Entity<Product>(); productConf.HasKey(p => p.Id); productConf.Property(p => p.Id).IsIdentity(); productConf.Property(p =>…

3

Tip 18 – How to decide on a lifetime for your ObjectContext

One of the most common questions we get is how long should an ObjectContext should live. Options often cited include one per: Function Form Thread Application Plenty of people are asking these types of questions, case in point here is a question on Stackflow. I am sure there are many more buried away on our…

12

Tip 12 - How to choose an Inheritance Strategy

What strategies does the Entity Framework support? The Entity Framework supports 3 primary inheritance strategies: Table Per Hierarchy (TPH): In TPH, all data for a type hierarchy is stored in one table, and there is a discriminator column that is used to establish the type of a particular row (i.e. ‘C’ for Car or ‘B’…

13