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:
public partial class TestPolimorphicRefsContext : OpenAccessContext
{
static MetadataContainer metadataContainer = new TestPolimorphicRefsMetadataSource().GetModel();
static BackendConfiguration backendConfiguration = new BackendConfiguration()
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.