Created
July 22, 2018 10:14
-
-
Save ivanpaulovich/b2e66b47612faf1a95ea23b70e772394 to your computer and use it in GitHub Desktop.
Module.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment