Geeks With Blogs

News Welcome to my programming blog. I am a software developer living in Hertfordshire, United Kingdom.

I've been a keen developer for over a decade, most of it spent on C#/.Net development with ever increasing amounts of Javascript and I am an avid biker as well.

Please feel free to leave a comment if you found a post useful :-).

My twitter handle is BikerDev.

My LinkedIn profile.
Ritesh Singh's Programming Blog .Net and more

I’ve been using Entity Framework for a few years now. I’ll admit to being a bit sceptical about it back in early 2010 when Entity Framework 4 (which was in fact the second version!) was released simply because something fairly fundamental like C# enumerations were not supported.

The other thing that I didn’t particularly like was the fact that it ran really slowly and it felt so heavy and by that I mean WCF heavy as if it was designed by a committee. Fast forward a few years and it looks like EF has gained widespread acceptance and deservedly so after a number of newer versions resolved issues that people complained about and they have added a ton of new features, but the fact that EF tended to be quite slow remained a problem on the projects that I worked on. Slow load times are a known issue, you only need to look at a few forums to see that.

Some months ago I came across this video by Julie Lerman about Entity Framework in Core Business Applications and DDD approaches which suggested an approach of not using a single DbContext class that spans the entire database but instead using multiple contexts where each context that contained DbSets only for related domain entities. It’s the last bit of using *related domain entities* that makes it such an elegant solution to the issue of start up time and also maintainability.

The in memory model map created on start up is much smaller because it’s got only the entities that you care about and not the entire database so there is a performance benefit.

I also find that when my DbContext contains only domain specific entities I have to think hard about whether the data that I am pulling from a domain class matches that domain. It’s all too easy to pull everything and that means data unrelated to your domain when your context is the whole universe!

Do checkout the video linked above if you get a chance, it makes living with Entity Framework easier.

Posted on Sunday, October 26, 2014 8:40 PM Entity Framework | Back to top


Comments on this post: Bounded Context in Entity Framework

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © BikerDev | Powered by: GeeksWithBlogs.net