Is it known that the first EF code became unusable with a DbContext containing a large number of DbSets?

I hope for a short tip to tell me about the weather. I must suspect (a) I did something wrong or (b) I am trying to do something that is not supported.

I generated the code for the DbContext

with tables from QuickBooks. It has a lot of tables that I will never use, but I figured it wouldn't hurt.

Everything was going fine until I tried to call SaveChanges()

after one insert on the Customer table. My test window was successful, but the execution time was 1 to 2 minutes.

Then I dropped everything except the Customer table and the two related tables and the same test passed in 2ms.

I am amazed at something at prime time as the entity framework does not handle hundreds of tables in context, so I figure I am probably doing something wrong. If not, I just want to know about it. I'm not complaining - I really don't need it.

One thought I could do what I am doing outside of the normal script is that I added all the tables in one giant migration. Can these binary migration objects get a reference at runtime, perhaps?

Here's the complete DbContext code I'm talking about: https://gist.github.com/4677208

+3


source to share


1 answer


Was the database up to date?

My guess is that the SaveChanges () call is generated by your database first, and it may take a while if there are many tables and / or some complex logic or large data transfer when initializing in the Seed method or elsewhere.



So, most likely it will take a long time to not just insert one Client, but generate the whole thing.

Try adding another client after you've migrated the first one and see how long it takes.

0


source







All Articles