Skip to content

Instantly share code, notes, and snippets.

@ibrahimozgon
Created April 3, 2019 11:24
Show Gist options
  • Save ibrahimozgon/20e47c663a6ad83e510b3c1e2834a8da to your computer and use it in GitHub Desktop.
Save ibrahimozgon/20e47c663a6ad83e510b3c1e2834a8da to your computer and use it in GitHub Desktop.
public class MyDbContext : DbContext
{
private readonly ILoggerFactory _loggerFactory;
public MyDbContext(DbContextOptions<MyDbContext> options, ILoggerFactory loggerFactory) : base(options)
{
_loggerFactory = loggerFactory;
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
//1
optionsBuilder.UseLoggerFactory(_loggerFactory);
base.OnConfiguring(optionsBuilder);
}
public DbSet<Product> Products { get; set; }
public DbSet<Category> Categories { get; set; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment