Skip to content

Instantly share code, notes, and snippets.

View elanderson's full-sized avatar

Eric Anderson elanderson

View GitHub Profile
@elanderson
elanderson / gist:1eb1c2452e1d8b5a3b5b
Last active August 29, 2015 14:25 — forked from tonysneed/gist:4cac4f4dae2b22e45ec4
Configure EF7 to Log to the Console
public static class DbContextExtensions
{
public static void LogToConsole(this DbContext context)
{
IServiceProvider contextServices = ((IDbContextServices)context).ScopedServiceProvider;
var loggerFactory = contextServices.GetRequiredService<ILoggerFactory>();
loggerFactory.AddConsole(LogLevel.Verbose);
}
}