src/Misc/EFTools/EntityDesign/VisualStudio/VsUtils.cs
// <summary>
//     This method checks if the passed <paramref name="schemaVersion" /> is the latest
//     supported in project (or supported at all).
// </summary>
// <returns>
//     True if the schema version matches the latest schema version supported by model, false otherwise.
// </returns>
// <remarks>
//     We use this method to determine if we can open an edmx file of the given <paramref name="schemaVersion" />.
//     In general we want to open only edmx files with the latest version of the schema supported in the project
//     with two exceptions:
//     - Misc project - any version can be opened
//     - A project that targets .NET Framework 4 and contains references to both System.Data.Entity.dll and
//     EF6 EntityFramework.dll in which case we allow opening both v2 and v3 edmx files.
//     If no EF dll is referenced by a project we use 1:1 mapping between schema version and .NET Framework version
//     i.e. v1 - .NET Framework 3.5, v2 - .NET Framework 4, v3 - .NET Framework 4.5 and later
// </remarks>
This method checks if the passed  is the latest
supported in project (or supported at all).
This method checks if the passed is the latest supported in project ( or supported at all ) .
public static bool SchemaVersionSupportedInProject(Project project, Version schemaVersion, IServiceProvider serviceProvider)
        {
            Debug.Assert(project != null, "project != null");
            Debug.Assert(EntityFrameworkVersion.IsValidVersion(schemaVersion), "invalid schema version");
            Debug.Assert(serviceProvider != null, "serviceProvider != null");
            if (IsMiscellaneousProject(project))
            {
                return true;
            }
            var efAssemblyVersions = GetInstalledEntityFrameworkAssemblyVersions(project).ToArray();
            var targetNetFrameworkVersion =
                NetFrameworkVersioningHelper.TargetNetFrameworkVersion(project, serviceProvider);
            if (efAssemblyVersions.Length == 0)
            {
                return schemaVersion == RuntimeVersion.GetSchemaVersionForNetFrameworkVersion(targetNetFrameworkVersion);
            }
            return efAssemblyVersions.Any(
                efAssemblyVersion =>
                RuntimeVersion.IsSchemaVersionLatestForAssemblyVersion(
                    schemaVersion, efAssemblyVersion, targetNetFrameworkVersion));
        }
public static bool SchemaVersionSupportedInProject ( Project project , Version schemaVersion , IServiceProvider serviceProvider ) { Debug . Assert ( project != null , " " ) ; Debug . Assert ( EntityFrameworkVersion . IsValidVersion ( schemaVersion ) , " " ) ; Debug . Assert ( serviceProvider != null , " " ) ; if ( IsMiscellaneousProject ( project ) ) { return true ; } var efAssemblyVersions = GetInstalledEntityFrameworkAssemblyVersions ( project ) . ToArray ( ) ; var targetNetFrameworkVersion = NetFrameworkVersioningHelper . TargetNetFrameworkVersion ( project , serviceProvider ) ; if ( efAssemblyVersions . Length == 0 ) { return schemaVersion == RuntimeVersion . GetSchemaVersionForNetFrameworkVersion ( targetNetFrameworkVersion ) ; } return efAssemblyVersions . Any ( efAssemblyVersion => RuntimeVersion . IsSchemaVersionLatestForAssemblyVersion ( schemaVersion , efAssemblyVersion , targetNetFrameworkVersion ) ) ; }
This method checks if the passed  is the latest
supported in project (or supported at all).
This method checks if the passed is the latest supported in project ( or supported at all ) .
// There may not be any references if this is a Misc project or the user created  // a new empty model and no Entity Framework assemblies have been added yet. In both  // cases we should allow the model to be opened in the designer.
True if the schema version matches the latest schema version supported by model, false otherwise.
True if the schema version matches the latest schema version supported by model false otherwise .
project
Project
schemaVersion
Version
serviceProvider
IServiceProvider
remarks
We use this method to determine if we can open an edmx file of the given .
In general we want to open only edmx files with the latest version of the schema supported in the project
with two exceptions:
Misc project - any version can be opened
A project that targets .NET Framework 4 and contains references to both System.Data.Entity.dll and
EF6 EntityFramework.dll in which case we allow opening both v2 and v3 edmx files.
If no EF dll is referenced by a project we use 1:1 mapping between schema version and .NET Framework version
i.e. v1 - .NET Framework 3.5, v2 - .NET Framework 4, v3 - .NET Framework 4.5 and later
We use this method to determine if we can open an edmx file of the given . In general we want to open only edmx files with the latest version of the schema supported in the project with two exceptions : Misc project - any version can be opened A project that targets . NET Framework 4 and contains references to both System . Data . Entity . dll and EF6 EntityFramework . dll in which case we allow opening both v2 and v3 edmx files . If no EF dll is referenced by a project we use 1 : 1 mapping between schema version and . NET Framework version i . e . v1 - . NET Framework 3 . 5 v2 - . NET Framework 4 v3 - . NET Framework 4 . 5 and later