Пример #1
0
        private void EnsureSeedData(ConfigurationDbContext configurationDbContext)
        {
            var isInit = false;

            if (configurationDbContext.Clients.Any() == false)
            {
                ClientsConfig.GetClients().ForEach(item =>
                {
                    configurationDbContext.Clients.Add(item.ToEntity());
                });
                isInit = true;
            }

            if (configurationDbContext.ApiResources.Any() == false)
            {
                ResourceConfig.GetApiResource().ForEach(item =>
                {
                    configurationDbContext.ApiResources.Add(item.ToEntity());
                });
                isInit = true;
            }

            if (configurationDbContext.IdentityResources.Any() == false)
            {
                ResourceConfig.GetIdentityResource().ForEach(item =>
                {
                    configurationDbContext.IdentityResources.Add(item.ToEntity());
                });
                isInit = true;
            }

            if (isInit)
            {
                configurationDbContext.SaveChanges();
            }
        }