src/Misc/EFTools/EntityDesignerVersioningFacade/ReverseEngineerDb/StoreSchemaConnectionFactory.cs
/// <summary>
///     Creates an EntityConnection loaded with the providers metadata for the latest available store schema.
///     Note that the targetEntityFrameworkVersion parameter uses internal EntityFramework version numbers as
///     described in the <see cref="EntityFrameworkVersion" /> class.
/// </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="maxAllowedSchemaVersion">The maximum allowed Entity Framework schema version that is being targeted.</param>
/// <param name="storeSchemaModelVersion">
///     The version of the store schema model supported by the provider. Can be either v1 or v3 (store schema model in v2 did not change
///     from v1, in v3 TVFs are supported and the provider needs to know how to handle Esql queries that ask for TVFs).
///     Note that schema view artifacts themselves are v1 since there is nothing that is needed to ask for v3 concepts that
///     cannot be expressed in v1 terms.
///     **This value MUST NOT be used as the version of the model that will be created for the user (which can be
///     any version regardless of this value), nor as the version of schema view artifacts (which is always v1)
///     but rather it is a version of concepts we are asking the provider to return details for (to put it simply if this is v3
///     we will ask the provider about TVFs, otherwise this is v1 and we don't ask about TVFs)**
/// </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 latest available store schema.
Note that the targetEntityFrameworkVersion parameter uses internal EntityFramework version numbers as
described in the  class.
Creates an EntityConnection loaded with the providers metadata for the latest available store schema . Note that the targetEntityFrameworkVersion parameter uses internal EntityFramework version numbers as described in the class .
public virtual EntityConnection Create(
            IDbDependencyResolver resolver, string providerInvariantName, string connectionString,
            Version maxAllowedSchemaVersion, out Version storeSchemaModelVersion)
        {
            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(maxAllowedSchemaVersion), "invalid maxAllowedSchemaVersion");
            var versions =
                EntityFrameworkVersion
                    .GetAllVersions()
                    .Where(v => v > EntityFrameworkVersion.Version2 && v <= maxAllowedSchemaVersion)
                    .OrderByDescending(v => v);
            foreach (var version in versions)
            {
                try
                {
                    storeSchemaModelVersion = version;
                    return
                        Create(
                            resolver,
                            providerInvariantName,
                            connectionString,
                            storeSchemaModelVersion);
                }
                catch (Exception e)
                {
                    if (!IsCatchableExceptionType(e))
                    {
                        throw;
                    }
                }
            }
            storeSchemaModelVersion = EntityFrameworkVersion.Version1;
            return Create(resolver, providerInvariantName, connectionString, storeSchemaModelVersion);
        }
public virtual EntityConnection Create ( IDbDependencyResolver resolver , string providerInvariantName , string connectionString , Version maxAllowedSchemaVersion , out Version storeSchemaModelVersion ) { Debug . Assert ( resolver != null , " " ) ; Debug . Assert ( ! string . IsNullOrWhiteSpace ( providerInvariantName ) , " " ) ; Debug . Assert ( ! string . IsNullOrWhiteSpace ( connectionString ) , " " ) ; Debug . Assert ( EntityFrameworkVersion . IsValidVersion ( maxAllowedSchemaVersion ) , " " ) ; var versions = EntityFrameworkVersion . GetAllVersions ( ) . Where ( v => v > EntityFrameworkVersion . Version2 && v <= maxAllowedSchemaVersion ) . OrderByDescending ( v => v ) ; foreach ( var version in versions ) { try { storeSchemaModelVersion = version ; return Create ( resolver , providerInvariantName , connectionString , storeSchemaModelVersion ) ; } catch ( Exception e ) { if ( ! IsCatchableExceptionType ( e ) ) { throw ; } } } storeSchemaModelVersion = EntityFrameworkVersion . Version1 ; return Create ( resolver , providerInvariantName , connectionString , storeSchemaModelVersion ) ; }
Creates an EntityConnection loaded with the providers metadata for the latest available store schema.
Creates an EntityConnection loaded with the providers metadata for the latest available store schema .
// We are going to try loading all versions of the store schema model starting from the newest. // The first version of the model that was shipped with EntityFrameworkVersions.Version1 and EntityFrameworkVersions.Version2 is the last one // we try, if it fails to load let the exception to propagate up to the caller. // Ignore the exception with the current version and try the next one.
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 .
maxAllowedSchemaVersion
Version
The maximum allowed Entity Framework schema version that is being targeted.
The maximum allowed Entity Framework schema version that is being targeted .
Version
out
storeSchemaModelVersion
The version of the store schema model supported by the provider. Can be either v1 or v3 (store schema model in v2 did not change
from v1, in v3 TVFs are supported and the provider needs to know how to handle Esql queries that ask for TVFs).
Note that schema view artifacts themselves are v1 since there is nothing that is needed to ask for v3 concepts that
cannot be expressed in v1 terms.
This value MUST NOT be used as the version of the model that will be created for the user (which can be
any version regardless of this value), nor as the version of schema view artifacts (which is always v1)
but rather it is a version of concepts we are asking the provider to return details for (to put it simply if this is v3
we will ask the provider about TVFs, otherwise this is v1 and we don't ask about TVFs)
The version of the store schema model supported by the provider . Can be either v1 or v3 ( store schema model in v2 did not change from v1 in v3 TVFs are supported and the provider needs to know how to handle Esql queries that ask for TVFs ) . Note that schema view artifacts themselves are v1 since there is nothing that is needed to ask for v3 concepts that cannot be expressed in v1 terms . This value MUST NOT be used as the version of the model that will be created for the user ( which can be any version regardless of this value ) nor as the version of schema view artifacts ( which is always v1 ) but rather it is a version of concepts we are asking the provider to return details for ( to put it simply if this is v3 we will ask the provider about TVFs otherwise this is v1 and we don ' t ask about TVFs )
remarks
virtual for testing
virtual for testing