Hi Kemal,
long time for creating a context instance is an indication that you do something extra. Typical reason for such timing could be code like this:
The above code creates once a MetadataSource instance and passes it each time to the constructor when it gets invoked. In this case the constructor calls a method which prepares the metadata each time, if you have lots of entities in the metadata this could be costly operation. If you have this patter in your code I would suggest you to change to the following:
Here as you can see the complete metadataContainer is prepared upfront once and then it is re-used in each and every context created after that. The first creation would still be slightly longer, might be comparable with the timing you mention but all next creations should be almost immediate.
PS: have in mind that if you apply some logic and modify the metadata inside the FluentMetadataSource the approach above will not work as the resulted metadataContainer will be cached the first time.
Hope this helps.
Regards,
Kaloyan Nikolov
Telerik
Check out the
latest announcement about Telerik Data Access vNext as a
powerful framework able to solve core development problems.