src/Misc/EFTools/EntityDesign/VisualStudio/RuntimeVersion.cs
// <summary>
//     Returns a target schema version for the <paramref name="entityFrameworkVersion" /> and
//     <paramref name="targetNetFrameworkVersion" />
// </summary>
// <param name="entityFrameworkVersion">The version of the referenced Entity Framework assembly.</param>
// <param name="targetNetFrameworkVersion">.NET Framework version tergeted by the project.</param>
// <returns>
//     A target schema version for the <paramref name="entityFrameworkVersion" /> and
//     <paramref name="targetNetFrameworkVersion" />
// </returns>
// <remarks>
//     Note that <paramref name="targetNetFrameworkVersion" /> is an auxiliary parameter used only when the target schema
//     version cannot be determined based solely on the <paramref name="entityFrameworkVersion" />. There are currently two cases when this can happen:
//     - <paramref name="entityFrameworkVersion" /> is null which means that neither EntityFramework.dll nor System.Data.Entity.dll
//     is referenced by the project in which case we returned the latest possible target schema version for the targeted .NET Framework
//     - <paramref name="entityFrameworkVersion" /> is 4.0.0.0 which means that the project references only System.Data.Entity.dll in which case
//     we need to use the target .NET Framework version to decide if this is EF4 or EF5 since the version of System.Data.Entity.dll is
//     4.0.0.0 on both .NET Framework 4 and .NET Framework 4.5 but EF4 supports only v2 schemas while EF5 supports v3 schemas.
// </remarks>
Returns a target schema version for the  and
Returns a target schema version for the and
public static Version GetTargetSchemaVersion(Version entityFrameworkVersion, Version targetNetFrameworkVersion)
        {
            Debug.Assert(
                entityFrameworkVersion == null || entityFrameworkVersion >= Version1,
                "entityFrameworkVersion is less than 3.5.");
            Debug.Assert(targetNetFrameworkVersion != null, "targetNetFrameworkVersion is null.");
            if (entityFrameworkVersion == null)
            {
                return GetLatestSchemaVersion(targetNetFrameworkVersion);
            }
            if (entityFrameworkVersion >= Version5Net45
                || (entityFrameworkVersion == Version4 &&
                    targetNetFrameworkVersion >= NetFrameworkVersioningHelper.NetFrameworkVersion4_5))
            {
                return EntityFrameworkVersion.Version3;
            }
            if (entityFrameworkVersion >= Version4)
            {
                return EntityFrameworkVersion.Version2;
            }
            Debug.Assert(entityFrameworkVersion == Version1);
            return EntityFrameworkVersion.Version1;
        }
public static Version GetTargetSchemaVersion ( Version entityFrameworkVersion , Version targetNetFrameworkVersion ) { Debug . Assert ( entityFrameworkVersion == null || entityFrameworkVersion >= Version1 , " " ) ; Debug . Assert ( targetNetFrameworkVersion != null , " " ) ; if ( entityFrameworkVersion == null ) { return GetLatestSchemaVersion ( targetNetFrameworkVersion ) ; } if ( entityFrameworkVersion >= Version5Net45 || ( entityFrameworkVersion == Version4 && targetNetFrameworkVersion >= NetFrameworkVersioningHelper . NetFrameworkVersion4_5 ) ) { return EntityFrameworkVersion . Version3 ; } if ( entityFrameworkVersion >= Version4 ) { return EntityFrameworkVersion . Version2 ; } Debug . Assert ( entityFrameworkVersion == Version1 ) ; return EntityFrameworkVersion . Version1 ; }
Returns a target schema version for the  and
Returns a target schema version for the and
A target schema version for the  and
A target schema version for the and
entityFrameworkVersion
Version
The version of the referenced Entity Framework assembly.
The version of the referenced Entity Framework assembly .
targetNetFrameworkVersion
Version
.NET Framework version tergeted by the project.
. NET Framework version tergeted by the project .
remarks
Note that  is an auxiliary parameter used only when the target schema
version cannot be determined based solely on the . There are currently two cases when this can happen:
is null which means that neither EntityFramework.dll nor System.Data.Entity.dll
is referenced by the project in which case we returned the latest possible target schema version for the targeted .NET Framework
is 4.0.0.0 which means that the project references only System.Data.Entity.dll in which case
we need to use the target .NET Framework version to decide if this is EF4 or EF5 since the version of System.Data.Entity.dll is
4.0.0.0 on both .NET Framework 4 and .NET Framework 4.5 but EF4 supports only v2 schemas while EF5 supports v3 schemas.
Note that is an auxiliary parameter used only when the target schema version cannot be determined based solely on the . There are currently two cases when this can happen : is null which means that neither EntityFramework . dll nor System . Data . Entity . dll is referenced by the project in which case we returned the latest possible target schema version for the targeted . NET Framework is 4 . 0 . 0 . 0 which means that the project references only System . Data . Entity . dll in which case we need to use the target . NET Framework version to decide if this is EF4 or EF5 since the version of System . Data . Entity . dll is 4 . 0 . 0 . 0 on both . NET Framework 4 and . NET Framework 4 . 5 but EF4 supports only v2 schemas while EF5 supports v3 schemas .