private DocumentDbMetadataCache GetOrCreateMetadataCache()
        {
            DocumentDbMetadataCache metadataCache;

            MetadataCache.TryGetValue(this.connectionString, out metadataCache);
            if (metadataCache == null)
            {
                metadataCache = new DocumentDbMetadataCache(ContainerName, RootNamespace);
                MetadataCache.Add(this.connectionString, metadataCache);
            }
            return(metadataCache);
        }
        public DocumentDbMetadata(string connectionString, DocumentDbConfiguration.Metadata metadata = null)
        {
            this.connectionString = connectionString;
            this.Configuration    = metadata ?? DocumentDbConfiguration.Metadata.Default;

            lock (MetadataCache)
            {
                this.instanceMetadataCache = GetOrCreateMetadataCache();
            }

            using (var context = new DocumentDbContext(connectionString))
            {
                PopulateMetadata(context);
            }
        }