Inject DbContext with Autofac

前端 未结 1 493
难免孤独
难免孤独 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()
      .AsImplementedInterfaces()
      .InstancePerLifetimeScope();
    

    0 讨论(0)
提交回复
热议问题