Introducing Entity Framework Unit Testing with TypeMock Isolator

by mosessaur| 06 September 2009| 7 Comments

Introduction

One of the challenging things with current version of Entity Framework, its leakage of testability. Which means when you build an application or module (e.g. Repositories) that depends on entity framework, it will be very hard to unit test your code isolated from Entity Framework. This might lead to conduct Integration Testing which will require a connection and interaction with underlying data store (database).

You might think of using to mock or fake Entity Framework data store dependent calls. But sadly and Rhino Mock mocking frameworks do not support this. And you’ll end up hitting the wall. Both frameworks are great useful and I personally use for a while now and very happy with it. But no one can deny limitations when exist.

And personally I was able to overcome the limitation of the testability of Entity Framework while I was working in  Entity Framework based models and repositories. But done that through unnecessary code refactoring and wrappers around none mockable classes such as sealed class EntityCollection<T>.

Finding a solution with TypeMock Isolator

In fact there is a solution, that will save you lots of workarounds and unnecessary code refactoring. You just need a full isolation framework. Isolator provides this capability. It allows to mock sealed classes and classes that have private constructors, static methods, and much more.

makes it easy to simulate and break the dependencies of any object in your existing code. In that way, it doesn’t force you to think about how your design might need to change. –The Art of Unit Testing book page 132-

So, TypeMock isolator is a perfect mate for testing code that has dependencies on Entity Framework as how I am going to show now.

More...

Multiple database support with Entity Framework

by mosessaur| 18 August 2009| 9 Comments

Introduction

One of the features introduced in Entity Framework is being database independent. Which mean each database provider can support Entity Framework by implementing its provider.

This feature allows you build applications independent from the underplaying database provider. In this post I’m going to show how to build an application that support multiple databases using same conceptual model made by Entity Framework.

Entity Framework providers

Entity Framework is database independent. Each database provider could have its own Entity Framework provider. Currently there are several database provider who support the current version of Entity Framework that is released with .Net 3.5 SP1.

A list of Entity Framework providers can be found .

Entity Framework multiple database support sample

In this post, I am going to demonstrate a sample application (based on northwind database) that is going to support both SQL Server database engine and MySQL database engine.

More...

Introducing Entity Framework v1 in DotNetWork User Group in Cairo Egypt

by mosessaur| 18 July 2009| 3 Comments

Bishoy Ghaly & me made an introductory presentation about Entity Framework for the first time in DotNetWork User Group in Cairo, Egypt –Saturday 18th July-

After a survey we made in June we discovered that an introductory session to Entity Framework is a must. So we prepared this 3 hours session -level 100- to introduce Entity Framework to the audiences.

More...

Silverlight 3 is out with SDK and Tools with useful links

by mosessaur| 11 July 2009| 0 Comments

Silverlight 3 is out, Scott Guthrie that on his blog. As I was started to upgrade my client, I thought it would be useful to search for the SDK and Silverlight 3 VS.NET tools too. Thought to share the following quick links for Silverlight 3

KiGG support for Entity Framework and MySQL

by mosessaur| 07 July 2009| 2 Comments

Introduction

is a Web 2.0 style social news web application developed in Microsoft supported technologies. It is an open source project hosted on CodePlex. It is live and running as DotNetShoutout.com.

KiGG and Entity Framework

On May 2009, I’ve completed the implementation of Entity Framework support on KiGG. KiGG design was very flexible to plug another repository implementation other than LINQ to SQL. So basically now KiGG comes with 2 repository flavours, LINQ to SQL and Entity Framework.

Read about .

More...

Microsoft ADO.NET Entity Framework Feature CTP 1 Post Beta 1

by mosessaur| 30 June 2009| 0 Comments

Microsoft ADO.Net team released (this month June 2009) a set of features that build on top of Entity Framework 4.0 Beta 1
The features included in this CTP are :

  1. that allows you to write Entity Data Model based applications without requiring external artifacts

CTP can be downloaded here

Enjoy it.

Entity Framework minimum permission considerations

by mosessaur| 21 May 2009| 3 Comments

Introduction

While working with Entity Framework v1 during implementation of Entity Framework repositories, I decided to test for partial trust environment. Particularly Medium Trust support. Will not go through whether currently support medium trust or not in it current or upcoming version, but I will go through one of the reasons why currently might not support medium trust. It is because MY implementation of Entity Framework. Note that I am saying MY, because Entity Framework application can run on medium trust.

More...

Entity Framework 4 Persistence-Ignorance First Look

by mosessaur| 20 May 2009| 5 Comments

Introduction:

From the moment I put my hands on Visual Studio.Net 2010 Beta 1 and I’m targeting EF4 –Entity Framework 4- as I was very excited to checkout the new cool feature of it.

Here I am going to highlight my first look at Persistence-Ignorance support in EF4.

More...

Introducing DataLoadOptions for Entity Framework ObjectContext

by mosessaur| 16 May 2009| 0 Comments

On my previous post “” I was suggesting another way to define eager loading for Entity Framework. In this post I will introduce my DataLoadOptions for Entity Framework ObjectContext.

The beginning:

Actually Eager and Lazy loading on Entity Framework is not that much fun like in Linq to Sql. However this is going to be improved in EF4.

Here I will focus on eager loading and my slight improvement to define eager loading in Entity Framework. When I start to think about, I wanted something simple and pretty close to the way Linq to Sql work. In Linq to Sql it is the DataLoadOptions that helps you define eager loading before start using Linq to Sql DataContext.

So I started to explore the DataLoadOptions code using reflector, to better understand how it works and how it helps Linq to Sql define eager loading.

More...