First time model load is slow
Posted: Wed 08 Feb 2012 09:08
The answer to this question may very well be "that's to be expected", but it can't hurt to ask.
We have a quite large model. There are roughly 200 entities, and some of the entities are themselves pretty big -- the average number of columns per entity is probably in the 10-20 range. We're using the DbContext template with database independent and fluent mapping set to true, and the generated OnModelCreating method is about 15,000 lines. We've customized the DbContext template somewhat, but I don't think there's anything we've done that should have an effect on any of this. We're using Entity Framework 4.2.
Right after the application starts, we create a DbContext and perform a dummy query to ensure that everything gets loaded. It takes over 20 seconds for the line with the dummy query to execute. The vast majority of that time is spent somewhere inside EntityFramework.dll. I can say for certain that it's not the OnModelCreating method itself that's the problem, as it executes in less than a second on my computer.
All subsequent Entity Framework operations are nice and quick, so this isn't the end of the world. Basically I'm just wondering if I have to expect this kind of load time with a model of my size, or if there's something you know about that I can do to shorten the load time?
We have a quite large model. There are roughly 200 entities, and some of the entities are themselves pretty big -- the average number of columns per entity is probably in the 10-20 range. We're using the DbContext template with database independent and fluent mapping set to true, and the generated OnModelCreating method is about 15,000 lines. We've customized the DbContext template somewhat, but I don't think there's anything we've done that should have an effect on any of this. We're using Entity Framework 4.2.
Right after the application starts, we create a DbContext and perform a dummy query to ensure that everything gets loaded. It takes over 20 seconds for the line with the dummy query to execute. The vast majority of that time is spent somewhere inside EntityFramework.dll. I can say for certain that it's not the OnModelCreating method itself that's the problem, as it executes in less than a second on my computer.
All subsequent Entity Framework operations are nice and quick, so this isn't the end of the world. Basically I'm just wondering if I have to expect this kind of load time with a model of my size, or if there's something you know about that I can do to shorten the load time?