public void Iserir(Tipo model) { using (DadosContext contexto = new DadosContext()) { contexto.Tipos.Add(model); contexto.SaveChanges(); } }
public void Editar(Tipo tipo) { using (DadosContext ctxt = new DadosContext()) { Tipo tipodb = BsucarPorId(tipo.Id); if (tipodb != null) { tipodb = tipo; ctxt.SaveChanges(); } } }
private void Inicializar(DadosContext context) { if (context != null) { context.Database.EnsureCreated(); if (!context.Usuarios.Any()) { var fake = new DadosFake(); context.Usuarios.AddRange(fake.Usuarios(100)); context.SaveChanges(); } } }