Last active
September 9, 2016 11:25
-
-
Save arman-hpp/4713f28ba7f389ac24e05c673f4f8f31 to your computer and use it in GitHub Desktop.
Disable Select EngineEdition on EF Code First
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// disable select cast(serverproperty('EngineEdition') as int) | |
/// <summary> | |
/// DbConfiguration | |
/// </summary> | |
public class CustomConfiguration : DbConfiguration | |
{ | |
public CustomConfiguration() | |
{ | |
SetDatabaseInitializer<DbContext>(null); | |
SetManifestTokenResolver(new CustomManifestTokenResolver()); | |
} | |
internal class CustomManifestTokenResolver : IManifestTokenResolver | |
{ | |
private readonly IManifestTokenResolver _defaultResolver = new DefaultManifestTokenResolver(); | |
public string ResolveManifestToken(DbConnection connection) | |
{ | |
var sqlConn = connection as SqlConnection; | |
//for SQLServer, 2008 or 2012 | |
return sqlConn != null ? "2012" : _defaultResolver.ResolveManifestToken(connection); | |
} | |
} | |
} | |
[DbConfigurationType(typeof(CustomConfiguration))] | |
public class MyContext : DbContext | |
{ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment