Tag: Entity Framework

How to Mock Entity Framework’s DbContext for Unit Testing

One of the frustrating things (there are more) when trying to mock Microsoft’s Entity Framework ORM is that it isn’t unit test friendly. In practice, I tend to wrap the Entity Framework classes in a repository abstraction layer, which gives me control over the interface, so writing unit tests becomes a relatively trivial exercise. The problem […]

New ASP.NET Training Course at Learning Tree

I was back in Learning Tree’s Reston offices last week, presenting the beta of my new ASP.NET course – Building ASP.NET Web Applications: Hands-On. (The beta is part of our course development process where we try out the course in front of students for the first time. Their feedback is an important part of refining […]

Exposing IQueryable/oData Endpoints With Web API

This is a follow on from my post on Web API and the Entity Framework. In that post, I showed a couple of approaches to dealing with JSON serialization problems in the Visual Studio 11 beta. Now I want to look at returning IQueryable from Web API methods. IQueryable allows you to do what it […]

Working With the Entity Framework and the Web API

In my last post, I talked about the new Web API controllers in MVC and showed how they work with simple data. In the real world, of course, I want them to work with my existing data, which uses Entity Framework. It turns out that this is far from straightforward (at least, in the beta). […]

Integrating Your Own Code with Entity Framework: The Factory

In my last post, I showed how to use the code-first technology in Entity Framework 4.1 to create your business entity classes and integrate them into EF. I’ll complete that code-first process in this post and add a warning about a limitation in the process compared to Entity Framework’s original data-first process. After defining your […]