Development With A Dot

Blog on development in general, and specifically on .NET

Sponsors

News

My Friends

My Links

Permanent Posts

Portuguese Communities

Browse by Tags

All Tags » Entity Framework Code First (RSS)
Tracing Entity Framework Code First Calls
Microsoft has published, some time ago, a set of Entity Framework providers , for adding caching and tracing capabilities to Entity Framework. One of these providers, tracing, is now available as a NuGet package . This offers an interesting functionality...
Entity Framework Pitfalls – Null Navigation Properties
What if, after you load an entity, you have a reference property for another entity that is null yet you are sure that it points to a valid record? This will likely be because of one of two things: Lazy loading is globally disabled (the LazyLoadingEnabled...
Entity Framework Pitfalls – Non Nullable Columns in Table Per Class Hierarchy Inheritance
When you use the Table Per Class Hierarchy inheritance mapping pattern ( Single Table Inheritance in Martin Fowler’s terminology), all properties of derived classes should map to nullable columns in the database. This should be pretty obvious: because...
Entity Framework Code First One to One With Cascade Delete
I recently had to figure how to achieve cascade deletes on a one to one mapping. The solution, I soon found out, required fluent configuration. Here’s some simple entities: 1: public class Principal 2: { 3: public Int32 PrincipalId { get; set; } 4: public...
Entity Framework Pitfalls – Cannot Return Complex Types From SQL Queries
Clarified: thanks, Diego! Methods in Entity Framework that return entities from SQL queries, such as DbSet<T>.SqlQuery and ObjectContext.ExecuteStoreQuery , cannot create complex types as parts of an entity. This is a known problem, whose resolution...
Entity Framework Pitfalls Index
Updated on September 22nd These are the posts on Entity Framework pitfalls I’ve written so far. This post will be updated whenever there are more. Validation Does Not Load Lazy Properties Migrations Require .NET 4.5 Concrete Table Inheritance and Identity...
Entity Framework Pitfalls – Concrete Table Inheritance and Identity Keys
When using the Concrete Table Inheritance / Table Per Concrete Type pattern for mapping entity inheritances, you cannot use IDENTITYs as primary keys. It is easy to understand why: because each entity of a concrete type is stored in its own table, and...
Entity Framework Code First Table Splitting
Since Entity Framework does not support lazy scalar properties, only lazy references and collections, in order to avoid automatic loading of columns with large contents – BLOBs or CLOBs – we can use a technique called table splitting. In a nutshell, this...
Entity Framework Pitfalls – Migrations Require .NET 4.5
Updated on 28-08: not sure how this problem appeared, but apparently this no longer happens. If you are to use Entity Framework Code First Migrations , you need to have your project set to use .NET 4.5, before getting the EntityFramework package from...
Entity Framework Pitfalls – Validation Does Not Load Lazy Properties
In a nutshell: Entity Framework Code First (EFCF) validation does not load lazy properties. If any of these properties is marked as required, and it is not loaded, a validation error will occur. While I understand the reason – imagine you are saving lots...
More Posts Next page »