Helping you solve those tough coding problems!
Learn some great web development and web design tips and techniques through recipes that clearly define the problem being solved with a working solution.
Popular Tags: cakephp | theory | optimization | javascript-development | css | asp-net | jquery-development | ajax | sql | php-development

Search:
Follow @endyourif rss Facebook LinkedIn

Entity Framework's Code-First with an ObjectContext Entity Framework's Code-First with an ObjectContext

Published on Mar 20, 2019 by Jamie Munro

If the following blog interests you, it's probably because you're using Entity Framework with a Code-First approach and whatever it is you are trying to do *must* use an ObjectContext instead of the standard DbContext. I'm sure, like me, you thought this shouldn't be too hard. Then you started hitting roadblocks like, Metadata is required in your connection string. What's metadata? This is only needed in Database-First so you can tell the framework where your edmx and other definition files are, so why do I need this with Code-First, I don't have these files?

This was definitely my first reaction as well. So after much trial-and-error and research, I have the solution!

Read more >

Tags: ASP.NET | c# | entity framework

Why the Repository Pattern Why the Repository Pattern

Published on May 20, 2013 by Jamie Munro

After the incredible reaction to a recent blog post, Entity Framework Beginnerís Guide Done Right, I feel like before writing some more code to further the basic example, Iíll take a step back and explain my beliefs in the repository pattern.

I was really overwhelmed with the reaction; what started with a simple 30 minute blogging effort has turned into something absolutely incredible.† The original post was really a starting point about not placing direct querying and saving to the database mingled with the core code.

Please note, these are my thoughts on the pattern based on current and previous pain points that Iíve/am experiencing and Iíd love to hear others input in making things better.

Read more >

Tags: ASP.NET | Theory | c# | entity framework | repository

Entity Framework Beginnerís Guide Done Right Entity Framework Beginnerís Guide Done Right

Published on May 13, 2013 by Jamie Munro

Entity framework is a great ORM provided by Microsoft.† There are a ton of examples of how to get up and running with it really quickly.† The only problem with all of them, is the get you off on the wrong foot.

In all of the EF example guides, the DbContext class is typically deeply embedded into the core of your code.† This of course is great for Entity framework because the effort to change will be next to impossible Ė speaking from experience of course here.

Instead, by making some subtle changes we can integrate Entity framework in a separate layer in case at some later date you wish to replace it.† Of course, you might never need to replace it, but following these simple techniques will allow better segregation of code and even provide simpler unit testing.

Read more >

Tags: ASP.NET | Theory | c# | entity framework