
While some conceptual pitfalls have made it from previous versions of EF, the EF Core team’s care in addressing previous problems was evident to me as I read through the EF Core documentation and worked on this post’s code samples. Getting started with EF Core is relatively straightforward, but mastering it can take an entire career.Īs a long-time user of earlier Entity Framework versions, I started writing this post with many preconceived notions about pitfalls from that experience. I want to be able to edit data for role when the popup comes up and load the table after saving.In this post, we’ll look at some pitfalls and ideas EF Core users like yourself may want to consider when developing an application.Įntity Framework Core (EF Core) is a ground-up rewrite of Microsoft’s object-database mapping framework. RoleTablePartialView.cshtml (var item in modal in Layout.cshtml + Add Html.PartialAsync("_RoleTablePartialView", Model) Layout = "~/Views/Shared/_Layout.cshtml" ViewData = new SelectList(_db.ApplicationUsers.Where(f => f.LockoutEnd = "Index" ViewBag.mgs = "This user already assign this role." Var isCheckRoleAssign = await _userManager.IsInRoleAsync(user, roleUser.RoleId) Var user = _db.ApplicationUsers.FirstOrDefault(c => c.Id = roleUser.UserId) ViewData = new SelectList(_db.ApplicationUsers.Where(f => f.LockoutEnd Assign(RoleUserVm roleUser) TempData = "Role has been deleted successfully" Var result = await _roleManager.DeleteAsync(role)

Public async Task DeleteConfirm(string id) Var role = await _roleManager.FindByIdAsync(id) TempData = "Role has been updated successfully" Var result = await _roleManager.UpdateAsync(role) Role = await _roleManager.FindByIdAsync(id) TempData = "Role has been saved successfully" Var result = await _roleManager.CreateAsync(role) ViewBag.mgs = "This role is aldeady exist" Var isExist = await _roleManager.RoleExistsAsync(role.Name)


Public async Task AddOrEdit(string id, string name) Var role = await _db.Roles.FindAsync(id) Public RoleController(RoleManager roleManager, UserManager userManager, ApplicationDbContext db) RoleController.cs using GoldenHands.Data Also when I save the data the view doesn't load the table, I have to refresh the page in order to view the data. The delete method works too, only the edit doesn't work. The create popup works, but when it comes to edit I can't get the id for role, in the controller the id comes as null.

I am new to ASP.NET Core MVC, and I'm trying to develop a popup modal for Edit and Create.
