public static async Task SeedAsync(LcpContext lcpContext, ILoggerFactory loggerFactory) { try { // Any checks for any records if (!lcpContext.Clients.Any()) { var clientsData = File.ReadAllText("../LCP.Infrastructure/SeedData/clients.json"); var clients = JsonSerializer.Deserialize <List <Client> >(clientsData); foreach (var client in clients) { lcpContext.Clients.Add(client); } await lcpContext.SaveChangesAsync(); } } catch (Exception ex) { var logger = loggerFactory.CreateLogger <LcpContextSeed>(); logger.LogError(ex.Message); } }
public ClientRepository(LcpContext lcpContext) { _lcpContext = lcpContext; }