예제 #1
0
        /// <summary>
        /// Initializes the database with default data to support other tables.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public static PimsContext SeedDatabase(this PimsContext context)
        {
            var countries                   = EntityHelper.CreateDefaultCountries();
            var regions                     = EntityHelper.CreateDefaultRegions();
            var organizationTypes           = EntityHelper.CreateDefaultOrganizationTypes();
            var organizationIdentifierTypes = EntityHelper.CreateDefaultOrganizationIdentifierTypes();

            context.AddRange(countries);
            context.AddRange(regions);
            context.AddRange(organizationTypes);
            context.AddRange(organizationIdentifierTypes);
            context.AddRange(EntityHelper.CreateDefaultRoles());
            context.AddRange(EntityHelper.CreateDefaultPropertyTypes());
            context.AddRange(EntityHelper.CreateDefaultPropertyClassificationTypes());
            context.AddRange(EntityHelper.CreateDefaultPropertyTenureTypes());
            context.AddRange(EntityHelper.CreateDefaultPropertyAreaUnitTypes());
            context.AddRange(EntityHelper.CreateDefaultDataSourceTypes());
            context.AddRange(EntityHelper.CreateDefaultContactMethodTypes());
            context.AddRange(EntityHelper.CreateDefaultProvinces(countries.First()));
            context.AddRange(EntityHelper.CreateDefaultDistricts(regions.First()));
            context.AddRange(EntityHelper.CreateDefaultOrganizations(organizationTypes.First(), organizationIdentifierTypes.First()));
            context.SaveChanges();
            return(context);
        }