Exemplo n.º 1
0
        private void SeedDatabase(IApplicationBuilder app)
        {
            var options = app
                          .ApplicationServices
                          .GetRequiredService <DbContextOptions <FamilyHelperContext> >();

            using (var context = new FamilyHelperContext(options))
            {
                //context.Database.EnsureDeleted();
                //context.Database.EnsureCreated();

                if (!context.Applications.Any())
                {
                    context.Applications.Add(new OpenIddictApplication <long>
                    {
                        ClientId          = "FamilyHelper.OpenIdConnect",
                        DisplayName       = "Family Helper Open Id Connect",
                        LogoutRedirectUri = "http://localhost:52334/signout-oidc",
                        RedirectUri       = "http://localhost:52334/signin-oidc",
                        Type = OpenIddictConstants.ClientTypes.Public
                    });

                    context.Applications.Add(new OpenIddictApplication <long>
                    {
                        ClientId     = "FamilyHelper.API",
                        ClientSecret = Crypto.HashPassword("secret_secret_secret"),
                        Type         = OpenIddictConstants.ClientTypes.Confidential
                    });
                }

                context.SaveChanges();
            }
        }
Exemplo n.º 2
0
 public UnitOfWork(FamilyHelperContext dbContext)
 {
     _dbContext = dbContext;
 }