IntroductionDatabase Logo

Suppose you wrote an application which uses the Entity Framework and you have to create a new feature which imports a large amount of data. Simple, right? Just iterate through the data you need to import, create the necessary entities, add them to the ObjectContext and call SaveChanges().

This approach might work fine, until you start to import a lot of data. As the amount of data increases, the performance of your application will suffer. If you want to do a bulk insert of data then the Entity Framework (or any other ORM) might not be the way to go.

Sometimes a bit of direct ADO.NET is required. The .NET Framework 2.0 introduced the SqlBulkCopy class which lets you bulk load a SQL Server table with data. Let’s see how we can combine the Entity Framework with the SqlBulkCopy class.

Read the rest of this entry »



For this article / tutorial I will demonstrate a quick and easy way on how to use data access objects (DAO’s) with the Entity Framework.

These data access objects form a layer between the business logic and the database access technology. The idea is that the business logic should remain ignorant of the technology used to access the database. Using this “DAO pattern” you can more easily interchange this backing technology.

In the text to come this will be demonstrated by setting up a simple domain model which will be modelled using the Entity Framework. Next a layer of DAO’s will be created on top of this domain model.

The business logic will only use these DAO’s to request or send back data from or to the underlying data store. How these CRUD operations are handled is entirely up to the implementation of the DAO’s and should be of no concert to the business logic.

By decoupling the business objects from the backing data store you can more easily switch to another database access technology such as for say Linq To Sql.

Read the rest of this entry »

Entity Framework ObjectContext

February 21, 2009

IntroductionWeb Development

It’s been a good two months since the last post. Today I finally found some spare time to write a new article about .NET. This will be the first article on this blog focusing solely on the Entity Framework. More in particular about using the Entity Framework in different environments such as Windows Applications and in an ASP.NET environment.

The Entity Framework has some drawbacks that will hopefully be addressed in the second release, but in its current state it’s already a really useful technology to use for database access.

This article will not discuss every feature of the Entity Framework as that would entail writing an entire book. The primary focus is on how to deal with the ObjectContext in different environments such as a regular Windows Application and a Web Application (ASP.NET). Let’s get started…

Read the rest of this entry »