Click here to Skip to main content
15,918,808 members
Please Sign up or sign in to vote.
0.00/5 (No votes)

I am using EF 5.0 and Code first approach in my project.
There are 10-15 tables in my database, and I have two context classes.
Now, for slow start up I have read a lot of articles and blogs. I found that installing
EF power tool will allow me to generate views which will help in improving the slow startup issue.
Previously for first call it was taking 40 seconds (for getting around 85 rows). After creating view, this time is reduced to 30 seconds.
Which is not significant considering that currently the database does not holds large data.
Further search suggested me to install EF CodeFirst View Generation T4 Template for C# and create View by this template.
But when i try creating View by this template using the steps in[^]

it gives me error :
Compiling transformation: 'System.Data.Entity.Design.EntityFrameworkVersions' does not contain a definition for 'Version3'

Why this happens?

Please suggest me something for improving the performance of EF 5.0 Code first.

Updated 20-Feb-13 18:03pm

I fixed the template a while ago so you should not see the error anymore.
Btw. for 10-15 tables pre-generated views should not really make much difference unless you map tables in a very specific ways. Also, 30-40 secs is very long for such a small dataset even for the first query.

Share this answer
DeepsMann 7-Aug-13 0:41am    
Hi Pawel
Thanks for reply.

I switched to database first in that project. Though I will try Code first and this template.
Till now i couldn't understand why it was taking 30-40 seconds.
I came to read everywhere that its too long time.
But why? Is it my WCF services, is it the network, database, IIS or Entity framework.
Because i tried using classic approach of using SQLConnection class and connecting to database. And its performance was much better. So, what is the benefit of using a functionality which lessen the performance of your site?
Please explain.

Sorry for such a long list of questions.
But I am not able to understand.

Thanks, again for your reply.
moozzyk 7-Aug-13 0:57am    
Hi Deepti,

Obviously ORMs will always add some overhead and sending SQL queries to the database will always be faster than using an ORM. On the other hand the overhead should not be prohibitive (30 secs feels prohibitive to me). To nail down the performance issue you need to identify which layer is causing the problem. You may not be able to tell where the problem is if you test end-to-end. I would start from creating a contained repro - a console, code first app that just sets up the model and sends a query to the database. If you have this you can create a work item on and report the issue. We do investigate performance problems/regressions. Finally, EF6 is now open source. You can try using EF6 instead of EF5. Since it is open source it is easier to profile/debug it. In addition, EF6 contains infrastructure for logging. It might be useful to tell whether the problem is in the EF or the database (btw. if the first query is slow but re-sending the same query is very fast than it most likely is an EF problem/misconfiguration).

If you are using .NET 4.5 and EF 5.0, you can download the T4 Template to pre-generate views from

This project contains a single T4 file to add to an existing C# project hosting Entity Framework 5.0 and targeting .NET 4.5. The source code of this project is a clone of ASP.NET Web Forms Application Using Entity Framework 4.0 Database First. The T4 template is copied from EF 5.0, and then fixed up to work with .NET 4.5.

This T4 template works with Database First approach. For Code First approach, you can use EF6 CodeFirst View Generation T4 Template for C#.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900