권한 요청이라는 모델이 있습니다.
public class PrivilegeRequests
{
public string UserEmail { get; set; }
public string AdminEmail { get; set; }
}
이 모델의 Db 컨텍스트를 만들었습니다.
public class PrivilegeRequestsDbContext : DbContext
{
public PrivilegeRequestsDbContext(DbContextOptions options) : base(options)
{
}
DbSet<PrivilegeRequests> Requests
{
get; set;
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<PrivilegeRequests>()
.HasKey(c => new { c.UserEmail, c.AdminEmail });
}
}
컨트롤러에서이 테이블의 모든 행을 가져오고 싶습니다. 컨트롤러에서 이미 컨텍스트를 초기화했습니다.
private PrivilegeRequestsDbContext _context;
public AdministrationController(RoleManager<IdentityRole> roleManager,UserManager<IdentityUser> userManager, PrivilegeRequestsDbContext context)
{
this.roleManager = roleManager;
this.userManager = userManager;
_context = context;
}
문제는 내가 _context를 입력했을 때의 행동입니다. 요청 테이블에 액세스 할 수 없어서 문제가 어디에 있는지 모르겠습니다.
Requests
다음을 통해 액세스하려면 public 으로 선언해야합니다 _context.Requests
.
public class PrivilegeRequestsDbContext : DbContext
{
....
public DbSet<PrivilegeRequests> Requests
{
get; set;
}
}
클래스 멤버의 기본 액세스 수정자는 비공개입니다 .
중첩 된 클래스 및 구조체를 포함한 클래스 및 구조체 멤버는 기본적으로 개인 액세스 권한을 갖습니다. 비공개 중첩 유형은 포함 유형 외부에서 액세스 할 수 없습니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다