Skip to content

Instantly share code, notes, and snippets.

@arman-hpp
Last active September 9, 2016 11:25
Show Gist options
  • Save arman-hpp/4713f28ba7f389ac24e05c673f4f8f31 to your computer and use it in GitHub Desktop.
Save arman-hpp/4713f28ba7f389ac24e05c673f4f8f31 to your computer and use it in GitHub Desktop.
Disable Select EngineEdition on EF Code First
// 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