0

아래의 설정으로 사용자를 찾으려고 할 때 스택 오버플로 오류가 발생합니다. 지연로드 (Lazy Loading) 및 프록시 생성 (Proxy Creation)을 해제하려고 시도했지만 오류가 계속 발생합니다. 모델 만들기에코드 첫 번째 EF6 자체 참조 다 대다 예외 스택 오버플로 오류

public class Authority 
{ 
    public int Id { get; set; } 
    public string Domain { get; set; } 
    public string Name { get; set; } 
    public AuthorityTypeEnum Type { get; set; } 
    public virtual List<Authority> Groups { get; set; } 
} 

:

protected override void OnModelCreating(DbModelBuilder modelBuilder) 
    { 
     modelBuilder.Conventions.Remove<ManyToManyCascadeDeleteConvention>(); 
     modelBuilder.Conventions.Remove<OneToManyCascadeDeleteConvention>(); 

     modelBuilder.Entity<Authority>() 
        .HasMany(a => a.Groups) 
        .WithMany(). 
        Map(m => 
         { 
          m.MapLeftKey("UserId"); 
          m.MapRightKey("GroupId"); 
          m.ToTable("UsersGroups"); 
         } 
        ); 

     base.OnModelCreating(modelBuilder); 
    } 

컨텍스트 생성자 :

var byUserAndDomain = db.Authorities 
         .FirstOrDefault(a => a.Type == AuthorityTypeEnum.User && a.Domain == MvcApplication.Domain && a.Name == MvcApplication.UserName); 
+0

방금 ​​MvcApplication.Domain 및 MvcApplication.UserName을 상수로 대체했으며 여전히 동일한 스택 오버플로 오류가 발생합니다. – RoboKitten

+0

재생할 수 없습니다. –

답변

0

내가 발견 : 이것은 스택 오버 플로우가 발생합니다 코드가

public Context() 
{ 
    this.Configuration.LazyLoadingEnabled = true; 
    this.Configuration.ProxyCreationEnabled = true; 
} 

발행물. 오류가 Linq 표현식이있는 행에서 발생했지만 재귀는 외부 범위에서 발생합니다. 엔티티 프레임은 내가 작업하고있는 객체의 재귀에 대해 가장 낮은 공차를 가지고 있다고 생각합니다.