public async Task <T> Add(T entity)
        {
            var dbEntity = _context.Set <T>().Add(entity).Entity;

            _context.SaveChanges();
            return(dbEntity);
        }
Beispiel #2
0
        public void RunSeed()
        {
            //Apagando e recriando o banco de dados
            _context.Database.EnsureDeleted();
            _context.Database.EnsureCreated();

            //Salvando os objetos e atribuindo as instâncias as variáveis do seed

            CreateProjectReservation();

            //Confirmando alterações
            _context.SaveChanges();
        }
Beispiel #3
0
        public static void PopulateTestData(ProjectsPortifolioDbContext dbContext)
        {
            dbContext.Project.Add(ProjectBuilder.Start().Build());

            dbContext.SaveChanges();
        }