0

다음 구조를 갖는 mvc5 프로젝트가 있습니다. enter image description here enter image description hereenter image description here enter image description hereenter image description hereMVC n 계층 아키텍처 프로젝트 종속성

enter image description here 아래 그림과 같이 내가 '엔티티'계층 내 DAL 층에서 DbContext 파일과 "ApplicationUserManager"클래스가

enter image description here

. '엔티티'계층의

enter image description here

'ApplicationUserManager'클래스 enter image description here 코드의 예를 다음있다.

public class ApplicationUserManager : UserManager<ApplicationUser> 
    { 
     public ApplicationUserManager(IUserStore<ApplicationUser> store) 
       : base(store) 
     { 
     } 
     public static ApplicationUserManager Create(IdentityFactoryOptions<ApplicationUserManager> options, IOwinContext context) 
     { 
      var manager = new ApplicationUserManager(new UserStore<ApplicationUser>(context.Get<ApplicationDbContext>())); 



Here, I am getting error : 
1. The type or namespace name 'ApplicationDbContext' could not be found (are you missing a using directive or an assembly reference? 
2. The type or namespace name 'DAL' does not exist in the namespace 'MVCFinal' (are you missing an assembly reference? 

이제 엔티티에 DAL 계층에 대한 참조를 추가하면 다른 많은 것들이 손상됩니다. 이 "ApplicationDbContext"오류를 엔터티 계층에서 어떻게 수정할 수 있습니까? n- 티어에서 레이어를 참조하는 올바른 방법은 무엇입니까?

감사합니다.

답변

3

문제는 순환 종속성이 허용되지 않으며 권장되지 않는 것입니다.

DAL은 엔티티 에 따라 달라 엔티티

은 일반 도서관과 당신이 당신의 엔티티 라이브러리에 DAL 라이브러리를 참조 할 필요가 없습니다 그 방법에 ApplicationDbContext 이동의 고려 DAL에 따라 달라집니다.

+0

예 원형 의존성 오류가 발생하지만 AppDbContext가 데이터 액세스와 관련하여 DAL에 있어야한다는 것을 알게되었습니다. – vicky

+0

@ user1829056에서 DAL에서 사용하는 엔티티 클래스 중 일부를 공용 라이브러리로 이동하고 엔티티 –

+0

에 대한 종속성을 제거 할 수 있지만이 경우 엔티티 (도메인 클래스)가 여러 프로젝트에 분산됩니다. 나는 그들을 단일 프로젝트에두고 싶다. – vicky