src/Misc/EFTools/EntityDesignerVersioningFacade/ReverseEngineerDb/StoreSchemaConnectionFactory.cs
/// <summary>
///     Creates an EntityConnection loaded with the providers metadata for the store schema.
/// </summary>
/// <param name="resolver">Resolver used to resolve provider services.</param>
/// <param name="providerInvariantName">The provider invariant name.</param>
/// <param name="connectionString">The connection for the providers connection.</param>
/// <param name="targetSchemaVersion">The target Entity Framework schema version that is being targeted.</param>
/// <returns>An EntityConnection that can query the ConceptualSchemaDefinition for the provider.</returns>
/// <remarks>virtual for testing</remarks>
Creates an EntityConnection loaded with the providers metadata for the store schema.
Creates an EntityConnection loaded with the providers metadata for the store schema .
public virtual EntityConnection Create(
            IDbDependencyResolver resolver, string providerInvariantName, string connectionString, Version targetSchemaVersion)
        {
            Debug.Assert(resolver != null, "resolver != null");
            Debug.Assert(!string.IsNullOrWhiteSpace(providerInvariantName), "providerInvarianName cannot be null or empty");
            Debug.Assert(!string.IsNullOrWhiteSpace(connectionString), "connectionString cannot be null or empty");
            Debug.Assert(EntityFrameworkVersion.IsValidVersion(targetSchemaVersion), "invalid targetSchemaVersion");
            SystemDataCommon.DbProviderFactory factory;
            try
            {
                factory = SystemDataCommon.DbProviderFactories.GetFactory(providerInvariantName);
            }
            catch (ArgumentException e)
            {
                throw new ArgumentException(
                    string.Format(
                        CultureInfo.CurrentCulture,
                        Resources_VersioningFacade.EntityClient_InvalidStoreProvider,
                        providerInvariantName),
                    e);
            }
            var providerConnection = factory.CreateConnection();
            if (providerConnection == null)
            {
                throw new ProviderIncompatibleException(
                    String.Format(
                        CultureInfo.CurrentCulture,
                        Resources_VersioningFacade.ProviderFactoryReturnedNullFactory,
                        providerInvariantName));
            }
            providerConnection.ConnectionString = connectionString;
            return new EntityConnection(
                GetProviderSchemaMetadataWorkspace(
                    resolver,
                    providerInvariantName,
                    providerConnection,
                    targetSchemaVersion),
                providerConnection);
        }
public virtual EntityConnection Create ( IDbDependencyResolver resolver , string providerInvariantName , string connectionString , Version targetSchemaVersion ) { Debug . Assert ( resolver != null , " " ) ; Debug . Assert ( ! string . IsNullOrWhiteSpace ( providerInvariantName ) , " " ) ; Debug . Assert ( ! string . IsNullOrWhiteSpace ( connectionString ) , " " ) ; Debug . Assert ( EntityFrameworkVersion . IsValidVersion ( targetSchemaVersion ) , " " ) ; SystemDataCommon . DbProviderFactory factory ; try { factory = SystemDataCommon . DbProviderFactories . GetFactory ( providerInvariantName ) ; } catch ( ArgumentException e ) { throw new ArgumentException ( string . Format ( CultureInfo . CurrentCulture , Resources_VersioningFacade . EntityClient_InvalidStoreProvider , providerInvariantName ) , e ) ; } var providerConnection = factory . CreateConnection ( ) ; if ( providerConnection == null ) { throw new ProviderIncompatibleException ( String . Format ( CultureInfo . CurrentCulture , Resources_VersioningFacade . ProviderFactoryReturnedNullFactory , providerInvariantName ) ) ; } providerConnection . ConnectionString = connectionString ; return new EntityConnection ( GetProviderSchemaMetadataWorkspace ( resolver , providerInvariantName , providerConnection , targetSchemaVersion ) , providerConnection ) ; }
Creates an EntityConnection loaded with the providers metadata for the store schema.
Creates an EntityConnection loaded with the providers metadata for the store schema .
An EntityConnection that can query the ConceptualSchemaDefinition for the provider.
An EntityConnection that can query the ConceptualSchemaDefinition for the provider .
resolver
IDbDependencyResolver
Resolver used to resolve provider services.
Resolver used to resolve provider services .
providerInvariantName
string
The provider invariant name.
The provider invariant name .
connectionString
string
The connection for the providers connection.
The connection for the providers connection .
targetSchemaVersion
Version
The target Entity Framework schema version that is being targeted.
The target Entity Framework schema version that is being targeted .
remarks
virtual for testing
virtual for testing