Guest User

Untitled

a guest
Jul 22nd, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. public class Module : Autofac.Module
  2. {
  3. public string ConnectionString { get; set; }
  4.  
  5. protected override void Load(ContainerBuilder builder)
  6. {
  7. var optionsBuilder = new DbContextOptionsBuilder<DbContext>();
  8. optionsBuilder.UseSqlServer(ConnectionString);
  9. optionsBuilder.EnableSensitiveDataLogging(true);
  10.  
  11. builder.RegisterType<Context>()
  12. .WithParameter(new TypedParameter(typeof(DbContextOptions), optionsBuilder.Options))
  13. .InstancePerLifetimeScope();
  14.  
  15. //
  16. // Register all Types in EntityFrameworkDataAccess namespace
  17. //
  18. builder.RegisterAssemblyTypes(typeof(InfrastructureException).Assembly)
  19. .Where(type => type.Namespace.Contains("EntityFrameworkDataAccess"))
  20. .AsImplementedInterfaces()
  21. .InstancePerLifetimeScope();
  22. }
  23. }
Add Comment
Please, Sign In to add comment