Original Article: @sitePage.OriginalLink
Contributed By: Carlos dos Santos
Published on: 2010-08-20
That article was published more than three years ago. Some content such as older Visual Studio version, "incoming" features, etc. might be outdated. However, the article may still be pertinent to read.
Improve Entity Framework Performance with EFProfiler
If you are working with EF4, you have probably wondered if the generated SQL commands are really optimized, or maybe when you have a performance problem. To answer that, several analysis tools or profilers exist, and one of these is the EFProfiler
.
The tool is quite simple. You download an executable from the website EF Profiler and follow the instructions contained in the file "How to use.txt".
For the profiler to work, you need to add a Profiler DLL reference to your project:
Then, in the main project file, you run the profiler initializer:
static void Main(string[] args) { // Profiler HibernatingRhinos.Profiler.Appender.EntityFramework.EntityFrameworkProfiler.Initialize(); TesteEntities dc = new TesteEntities(); var datas = from c in dc.Client select c; foreach (var data in datas) { Console.WriteLine(data.Name); } }
In the example above, we have a simple query to the database.
Now open the profiler and run your application, the results will appear on the screen:
That's it folks, a good profiler for you!