Add/Attach and Entity States

https://michye.wordpress.com/?p=101&preview=true

This topic will cover how to add and attach entities to a context and how Entity Framework processes these during SaveChanges. Entity Framework takes care of tracking the state of entities while they are connected to a context, but in disconnected or N-Tier scenarios you can let EF know what state your entities should be in. The techniques shown in this topic apply equally to models created with Code First and the EF Designer.

Advertisements

Performance Considerations for Entity Framework 4, 5, and 6

http://msdn.microsoft.com/en-us/data/hh949853.aspx

The following topics are covered in this article:

  Read more of this post

Entity Framework and SQL Server View

http://stackoverflow.com/questions/1013333/entity-framework-and-sql-server-view/2715299#2715299

To force entity framework to use a column as a primary key, use ISNULL.

To force entity framework not to use a column as a primary key, use NULLIF.

An easy way to apply this is to wrap the select statement of your view in another select.

Read more of this post

Cool (and Free) Tools for Entity Framework

http://msdn.microsoft.com/en-us/magazine/dn759438.aspx

Now that Entity Framework is open source, the development community is able to contribute code to it at entityframework.codeplex.com. But don’t limit yourself to looking there for tools and extensions. There are other great tools, both commercial and community-driven, that can help you achieve more with Entity Framework. In this column, I want to highlight some of those tools and extensions that come from the community. They’re all free and available through the Visual Studio Gallery (for IDE extensions) or NuGet (for code libraries). There are even some from members of the Entity Framework team that are pet projects and external to the official bits.

Read more of this post

Tips for Updating and Refactoring Your Entity Framework Code, Part 2

 Last month I discussed updating to EF6, using an old EF4 application as an example (bit.ly/1jqu5yQ). I also provided tips for breaking out smaller Entity Data Models from large models (EDMX or Code First), because I recommend working with multiple focused models rather than using one large model—laden with the complication of often unnecessary relationships—throughout your entire application.

This month, I’ll use a specific example to share more details about breaking out a small model, and then, using that small model, work through some of the problems you encounter when switching from the ObjectContext API to the newer DbContext API. 

Read more of this post

Tips for Updating and Refactoring Your Entity Framework Code

http://msdn.microsoft.com/en-us/magazine/dn683792.aspx

I have worked with many clients to help refactor existing software that uses Entity Framework (EF). In the case of EF code, refactoring can have a variety of meanings and often involve an update. In this column, I’ll take a look at some of the ways you might be overhauling your EF code, or applications that involve EF. For each of these approaches, I’ll provide some guidance—based on my experiences working with clients’ production applications—that should help you be well-prepared and avoid some headaches.

The changes I’ll discuss are:

  • Updating to a new version of Entity Framework
  • Breaking up a large Entity Data Model
  • Replacing the ObjectContext API with the DbContext API

Read more of this post

Profiling Database Activity in the Entity Framework

http://msdn.microsoft.com/en-us/magazine/gg490349.aspx