public async Task <IActionResult> Create([Bind("Id,Name,Grade")] TemplateEntity entity) { if (ModelState.IsValid) { _context.Add(entity); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["Grade"] = new SelectList(_context.Template2Classes, "Grade", "Grade"); return(View(entity)); }
public void Add <T>(T entity) where T : class { _context.Add(entity); _context.SaveChanges(); }