Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Module : Autofac.Module
- {
- public string ConnectionString { get; set; }
- protected override void Load(ContainerBuilder builder)
- {
- var optionsBuilder = new DbContextOptionsBuilder<DbContext>();
- optionsBuilder.UseSqlServer(ConnectionString);
- optionsBuilder.EnableSensitiveDataLogging(true);
- builder.RegisterType<Context>()
- .WithParameter(new TypedParameter(typeof(DbContextOptions), optionsBuilder.Options))
- .InstancePerLifetimeScope();
- //
- // Register all Types in EntityFrameworkDataAccess namespace
- //
- builder.RegisterAssemblyTypes(typeof(InfrastructureException).Assembly)
- .Where(type => type.Namespace.Contains("EntityFrameworkDataAccess"))
- .AsImplementedInterfaces()
- .InstancePerLifetimeScope();
- }
- }
Add Comment
Please, Sign In to add comment