Showing all posts tagged: 'Entity Framework'

A 8-post collection

EF Core migrations with existing database schema and data

I'm currently working on an inherited .NET Core project and I'm loving the experience. I'm still using the project.json project format instead of the newer *.csproj & msbuild one. For now I'll leave it as it is but going forward I'll use the new format for subsequent ASP.NET Core projects. The project also makes use of the newest EF Core so it's all running on the edge of the .NET technology. EF Core Code First is great but the tooling is still rough around the edges. Some things are not there or some of them are not feature …[read more]


Entity Framework Core 1.0 - Table Valued Functions and LINQ Composition

Entity framework Core (EFCore) has been out for a few weeks now after hitting RTM on June 27th 2016. That was also the same day that ASP.NET Core was released. EFCore has brought many changes, to say the least. It was renamed to Core instead the logical continuation from Entity Framework, because it's a total rewrite. Very similar to ASP.NET Core. The rewrite brought many benefits with speed being the biggest one. EF Core is simpler and a lot more powerful, even though it's still early days and some things are not working as expected or are missing. …[read more]


Performance issues with multiple includes and large object graphs - Entity Framework

Entity Framework (EF), Microsoft's ORM answer to nHibernate, is an excellent tool. I've used it many times in many projects. It's easy to get started and set up, it's versatile and has good support. Unfortunately, as with every other tool, there are pitfalls. The larger a project gets, the harder it becomes to use EF straight out-of-the-box. As your objects and relationships grow, your queries need to become more intelligent. More refined. There are many ways to mitigate performance issues, BDD, multiple contexts, query optimization, AutoMapper, etc. I could probably do another post or posts just on this subject! And …[read more]


The specified type member 'Date' is not supported in LINQ to Entities Exception - Entity Framework

EntityFramework is great when it works. You almost don't know it's there, doing its magic in the background while you focus on building your application around your models. However, when it breaks or doesn't work in the way you expect it, you're in for a ride. This morning I spent a bit of time trying to figure out why I was getting the following error on a seemingly straightforward query: The specified type member 'Date' is not supported in LINQ to Entities Exception So, why is this failing? The answer to the question is simple: "LINQ to Entities cannot translate …[read more]


Logging and tracing with Entity Framework 6

Logging is important, especially when you have to troubleshoot an issue. That's when you realize that without logging you are "driving blind". Today's post is about logging with Entity Framework 6. I agree that there are tools out there that can help you with EF troubleshooting, such as Glimpse (if you are on a web application), SQL Server profiling etc. However, EF6 makes it extremely easy to log and trace executed statements and in this post I will show you how you can leverage this feature to create a robust and efficient logging solution for your application. Simple logging If …[read more]


Generic Repository with Entity Framework

My first NuGet package and OSS project is live :) What an exciting day! Lots of new releases announced in the last couple of days so why not add to the funfair and release my own OSS? This is a piece of code that I had to develop for a client and it took some effort. During the development of this library I tried to make as generic and modular as possible, which made it quite easy when I decided to share it with the community. The project is now live and there is a public repo on GitHub in hope …[read more]