开发者

EF: How do I decrease the very first DataContext initialization time

开发者 https://www.devze.com 2023-02-18 22:24 出处:网络
I use auto generated Entity-Framework Data Model for a Database that has 100+ tables. Though I use only 5 tables I select all tables to be mapped onto c# classes.

I use auto generated Entity-Framework Data Model for a Database that has 100+ tables. Though I use only 5 tables I select all tables to be mapped onto c# classes.

Every time I start dekstop application that creates DataContext instance in FormLoad event it takes 3-4 seconds for some inner EF initialization. This 开发者_如何学Gostartup time strongly depends on number of autogenerated classes. When I decided to generate mapping only for 5 tables - start up time decreased dramatically.

I wonder what is going on behind the scenes and can I change standard behavior keeping all unused table mappings in a program? I don't want to care what tables do I need to be mapped. I guess EF does some reflection work, may it be done in lazy-load style or some of a kind?

Thank you in advance!


I recommend reading these two articles Part 1 and Part 2. They explain what happens when you start the application and how to reduce startup time by pregenerating Views for entity framework. Anyway including tables which you don't need is bad approach and nothing will reduce your startup time more then simply removing them from entity model.

0

精彩评论

暂无评论...
验证码 换一张
取 消