public static void Initialize(IServiceProvider serviceProvider) { var serviceScope = serviceProvider.CreateScope(); using (TransferDBContext context = serviceScope.ServiceProvider.GetRequiredService <TransferDBContext>()) { try { context.Database.Migrate(); } catch (Exception ex) { } if (!context.TransferLogs.Any()) { context.TransferLogs.Add(new TransferLog { FromAccount = 1, ToAccount = 2, TrasnferAmount = 100 }); context.SaveChanges(); } } }
public void Add(TransferLog transferLog) { _ctx.TransferLogs.Add(transferLog); _ctx.SaveChanges(); }
public void Add(TransferLog transferLog) { _context.Add(transferLog); _context.SaveChanges(); }
public void Add(TransferLog transferLog) { _transferDBContext.TransferLogs.Add(transferLog); _transferDBContext.SaveChanges(); }