Inject DbContext with Autofac

前端 未结 1 492
难免孤独
难免孤独 2020-12-16 01:38

I have the following EntityFramework context:

public class Context : DbContext, IDbContext {
}

Where IDbContext is the following:



        
相关标签:
1条回答
  • 2020-12-16 02:06

    Many ways, depending on scope you need, conventions etc.

    Example:

    containerBuilder
      .RegisterType<Context>()
      .AsImplementedInterfaces()
      .InstancePerLifetimeScope();
    
    0 讨论(0)
提交回复
热议问题