Entity Framework taking a lot of time initializing model!
-
Monday, January 14, 2013 3:59 PM
I have a model with the following hierarchy. There are around 20 classes which are derived from A1, and about 30 classes which derive from A2.
The model is being saved using TPH into a single table.
The issue is that just creating a single instance of type 'A', adding it to a List<A> property of another entity and committing those changes is taking a lot of time. At this moment, it has already taken about 2.5 hours, and still hasn't committed the changes yet!
All Replies
-
Monday, January 14, 2013 7:57 PMModerator
Hi,
There are a few things you can do to increase the performance of initializing your model. Details on all of them can be found in this document: http://msdn.microsoft.com/en-us/data/hh949853
The answer will probably be to use compiled views, which moves the cost of view generation to compile time instead of execution time. There is also some other guidance in the document but I don't know how much it will apply to this scenario.
Another thing is that we have made improvements to view generation in EF6. Are you able to try this model out with a nightly build of EF6 to see how much it improves? You can find out how to get a nightly build here if you are interested in trying it: http://entityframework.codeplex.com/wikipage?title=Nightly%20Builds
We are seeing a lot of great Entity Framework questions (and answers) from the community on Stack Overflow. As a result, our team is going to spend more time reading and answering questions posted on Stack Overflow. We would encourage you to post questions on Stack Overflow using the entity-framework tag. We will also continue to monitor the Entity Framework forum.
- Marked As Answer by Trainee4Life Tuesday, January 15, 2013 4:44 AM
- Unmarked As Answer by Trainee4Life Tuesday, January 15, 2013 5:30 AM
-
Tuesday, January 15, 2013 8:10 AM
Tried with EF6 Alpha2, same observations!Another thing is that we have made improvements to view generation in EF6. Are you able to try this model out with a nightly build of EF6 to see how much it improves? You can find out how to get a nightly build here if you are interested in trying it: http://entityframework.codeplex.com/wikipage?title=Nightly%20Builds
-
Tuesday, January 15, 2013 6:21 PMModeratorYes, the changes I was talking about didn't make it to Alpha2. You would need to get a nightly build.
We are seeing a lot of great Entity Framework questions (and answers) from the community on Stack Overflow. As a result, our team is going to spend more time reading and answering questions posted on Stack Overflow. We would encourage you to post questions on Stack Overflow using the entity-framework tag. We will also continue to monitor the Entity Framework forum.
-
Wednesday, January 16, 2013 2:56 AM
Yes, the changes I was talking about didn't make it to Alpha2. You would need to get a nightly build.
Now, how would I get a nightly build? I had configured NuGet to get packages from http://www.myget.org/F/aspnetwebstacknightly/, and that's how I managed to get the EF6 Alpha2 release. Is there anything I might be missing here? -
Wednesday, January 16, 2013 4:24 AMModerator
If you retrieved the package from aspnetwebstacknightly then you are doing the correct thing. I (incorrectly) assumed that you had just used the -pre tag against the normal feed to get alpha2. But you're right that the nightly would also be called alpha 2 as we haven't changed the name.
It's interesting that there is no improvement, it might be that the changes don't improve your exact scenario. Can you give me the model that you are using? I'd like to get our perf engineer to take a look and see if there is something we can do to speed it up.
We are seeing a lot of great Entity Framework questions (and answers) from the community on Stack Overflow. As a result, our team is going to spend more time reading and answering questions posted on Stack Overflow. We would encourage you to post questions on Stack Overflow using the entity-framework tag. We will also continue to monitor the Entity Framework forum.
-
Wednesday, January 16, 2013 6:20 AMWhere can I mail you the files? Also, let's discuss it off this forum, I don't want to get the model details out. After our discussion we can always post our findings here and mark it as answer to anyone else facing similar issues.
-
Wednesday, January 16, 2013 7:14 PMModerator
That's fine. glennc <at> Microsoft .com is my email address.
We are seeing a lot of great Entity Framework questions (and answers) from the community on Stack Overflow. As a result, our team is going to spend more time reading and answering questions posted on Stack Overflow. We would encourage you to post questions on Stack Overflow using the entity-framework tag. We will also continue to monitor the Entity Framework forum.

