public async Task InsertAsync(Customer entity) { using (var ctx = new ImaginCrudContext()) { if (await ctx.Customers.AnyAsync(x => x.CustomerId.Equals(entity.CustomerId))) { throw new DuplicatedEntityException($"Ya existe un cliente con número de documento {entity.CustomerId}."); } } }
public void Insert(List <Customer> entity) { using (var ctx = new ImaginCrudContext()) { foreach (var item in entity) { if (ctx.Customers.Any(x => x.CustomerId.Equals(item.CustomerId))) { throw new DuplicatedEntityException($"Ya existe un cliente con número de documento {item.CustomerId}."); } } } }
private void _MigrateDataBase() { Logger.Info("Iniciando migración"); try { using (var db = new ImaginCrudContext()) { db.Database.Migrate(); } } catch (Exception ex) { Logger.Error("Error ejecutando la migración de la base de datos", ex); } }