コード例 #1
0
        public static async Task SeedAsync(IApplicationBuilder applicationBuilder, ILoggerFactory loggerFactory)
        {
            var config = applicationBuilder
                         .ApplicationServices.GetRequiredService <IOptions <LocationSettings> >();

            ctx = new LocationsContext(config);

            if (!ctx.Locations.Database.GetCollection <Locations>(nameof(Locations)).AsQueryable().Any())
            {
                await SetIndexes();
                await SetUSLocations();
            }
        }
コード例 #2
0
        public static async Task SeedAsync(IApplicationBuilder applicationBuilder, ILoggerFactory loggerFactory)
        {
            trace.Record(Annotations.LocalOperationStart("LocationsContextSeed:SeedAsync"));
            var config = applicationBuilder
                         .ApplicationServices.GetRequiredService <IOptions <LocationSettings> >();

            ctx = new LocationsContext(config);

            if (!ctx.Locations.Database.GetCollection <Locations>(nameof(Locations)).AsQueryable().Any())
            {
                await SetIndexes();
                await SetNorthAmerica();
                await SetSouthAmerica();
                await SetAfrica();
                await SetEurope();
                await SetAsia();
                await SetAustralia();
                await SetBarcelonaLocations();
            }
            trace.Record(Annotations.LocalOperationStop());
        }