private static void LoadStoreItemCollections(
            MetadataWorkspace workspace,
            DbConnection storeConnection,
            DbConnectionOptions connectionOptions,
            EdmItemCollection edmItemCollection,
            MetadataArtifactLoader artifactLoader)
        {
            Debug.Assert(
                workspace.IsItemCollectionAlreadyRegistered(DataSpace.CSpace), "C-Space must be loaded before loading S or C-S space");

            // The provider connection string is optional; if it has not been specified,
            // we pick up the store's connection string.
            //
            var providerConnectionString = connectionOptions[EntityConnectionStringBuilder.ProviderConnectionStringParameterName];
            if (string.IsNullOrEmpty(providerConnectionString)
                && (storeConnection != null))
            {
                providerConnectionString = storeConnection.ConnectionString;
            }

            // Build a string as the key and look up the MetadataCache for a match
            var storeCacheKey = CreateMetadataCacheKey(
                artifactLoader.GetOriginalPaths(),
                connectionOptions[EntityConnectionStringBuilder.ProviderParameterName],
                providerConnectionString);

            // Load store metadata.
            object entryToken;
            var mappingCollection =
                MetadataCache.GetOrCreateStoreAndMappingItemCollections(
                    storeCacheKey,
                    artifactLoader,
                    edmItemCollection,
                    out entryToken);

            workspace.RegisterItemCollection(mappingCollection.StoreItemCollection);
            workspace.RegisterItemCollection(mappingCollection);

            // Adding the store metadata entry token to the workspace
            workspace.AddMetadataEntryToken(entryToken);
        }
        private static EdmItemCollection LoadEdmItemCollection(MetadataWorkspace workspace, MetadataArtifactLoader artifactLoader)
        {
            // Build a string as the key and look up the MetadataCache for a match
            var edmCacheKey = CreateMetadataCacheKey(artifactLoader.GetOriginalPaths(DataSpace.CSpace), null, null);

            // Check the MetadataCache for an entry with this key
            object entryToken;
            var edmItemCollection = MetadataCache.GetOrCreateEdmItemCollection(
                edmCacheKey,
                artifactLoader,
                out entryToken);
            workspace.RegisterItemCollection(edmItemCollection);

            // Adding the edm metadata entry token to the workspace, to make sure that this token remains alive till workspace is alive
            workspace.AddMetadataEntryToken(entryToken);

            return edmItemCollection;
        }