본문 바로가기
MySql

MySQL ASP.NET/Identity 오류 : ApplicationUser 엔터티 유형이 현재 컨텍스트에 대한 모델의 일부가 아닙니다.

by 베이스 공부 2020. 12. 9.
반응형


asp.net ID 데이터 테이블을 다시 생성하든 관계없이 사용자 관리자에 액세스하자마자 응용 프로그램이 질식합니다.

The entity type ApplicationUser is not part of the model for the current context.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.InvalidOperationException: The entity type ApplicationUser is not part of the model for the current context.

Source Error:  

Line 65:             ' Create a local login before signing in the user
Line 66:             Dim user = New ApplicationUser() With {.UserName = model.UserName}
**Line 67:             Dim result = Await UserManager.CreateAsync(User, model.Password)**
Line 68:             If result.Succeeded Then
Line 69:                 Await SignInAsync(User, isPersistent:=False)

내 DbContext 모델에서 ApplicationDBContext를 가리 켰습니다.

Public Class ApplicationDbContext
    Inherits IdentityDbContext(Of ApplicationUser)
    Public Sub New()
        MyBase.New("IMSEntities")
    End Sub
End Class

인터넷 검색은 자신의 보안 공급자를 포기하고 코딩 한 사람들을 찾는 경향이 있습니다. 가능하면 표준 공급자를 사용하고 싶습니다. 당황!

 

해결 방법

 

(무효?) 솔루션 :


<add name="IMSSecurityEntities" connectionString="data source=localhost;database=mydb;Uid=id;Pwd=password;" providerName="mysql.data.mysqlclient"/>

마찬가지로 신원 모델은 다음과 같이 조정되어야합니다.

Public Class ApplicationDbContext
    Inherits IdentityDbContext(Of ApplicationUser)
    Public Sub New()
        MyBase.New("IMSSecurityEntities")
    End Sub

이로 인해 ORM을 통해 보안 엔티티에 액세스하는 것이 불안해집니다.하지만 의도적으로 설계된 것일 수 있으므로 손실이 없을 수도 있습니다.

 

참조 페이지 https://stackoverflow.com/questions/22592770

 

 

반응형

댓글