public static async Task SeedEventDbEntityAsync <T>(this EventDbContext context, IQueryable <EntityBase> entities, ILogger logger = null) where T : EntityBase { string seedFile = Path.Combine(AppContext.BaseDirectory, "Seed", "EventDB", $"{typeof(T).Name}.json"); if (File.Exists(seedFile) && !(await entities.ToListAsync()).Any()) { logger?.LogInformation($"Seeding {context.GetType().Name}::{typeof(T).Name} with {seedFile}"); List <T> seedEntities = JsonConvert.DeserializeObject <List <T> >(await File.ReadAllTextAsync(seedFile)); await context.AddRangeAsync(seedEntities); await context.SaveChangesAsync(); logger?.LogInformation($"Seeding of {context.GetType().Name}::{typeof(T).Name} has completed!"); } }