// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { // add nhibernate var cfg = new Configuration(); var configFile = Path.Combine( Directory.GetCurrentDirectory(), "config", "hibernate.config" ); cfg.Configure(configFile); var isDev = env.IsDevelopment().ToString(); cfg.SetProperty(NHibernate.Cfg.Environment.ShowSql, isDev); cfg.SetProperty(NHibernate.Cfg.Environment.FormatSql, isDev); cfg.AddIdentityMappings(); cfg.AddAttributeMappingAssembly(typeof(Startup).Assembly); services.AddHibernate(cfg); // add identity services.AddIdentity <AppUser, AppRole>() .AddDefaultTokenProviders() .AddHibernateStores(); services.AddSingleton <IAuthorizationPolicyProvider, AuthorizationPolicyProvider>(); services.AddSingleton <IPasswordHasher <AppUser>, PasswordHasher>(); services.AddControllers(); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = "IdentityWebDemo", Version = "v1" }); }); }
private void ConfigureHibernateServices(IServiceCollection services, IWebHostEnvironment env) { var cfg = new Configuration(); var configFile = Path.Combine("config", "hibernate.config"); cfg.Configure(configFile); var isDevelopment = env.IsDevelopment().ToString(); cfg.SetProperty(Environment.ShowSql, isDevelopment); cfg.SetProperty(Environment.FormatSql, isDevelopment); cfg.AddIdentityMappings(); cfg.AddAttributeMappingAssembly(typeof(Beginor.NetCoreApp.Data.ModelMapping).Assembly); services.AddHibernate(cfg); }