this 질문과 동일한 문제가 발생하지만 거기에 제시된 시나리오는 적용되지 않는 것으로 보이므로 다른 문제가 있다고 생각합니다. 사실, 나는 서로 다른 원인과 해결책을 가진 유사한 몇 가지 질문을보고 있습니다. 그래서이 오류는 높은 수준에서 발생해야한다고 생각합니다. 그건 ...엔티티 유형 IdentityUser는 현재 컨텍스트 모델의 일부가 아닙니다.
저는 EF 코드 우선 데이터베이스 모델을 가지고 있으며, MVC 5 사이트의 표준 등록을 연장하기 위해 IdentityUser
을 사용하려고합니다.
내가 가진 내 확장 UserModel
:
namespace MyMvcSite.Models {
public class UserModel :IdentityUser {
public string BillingId { get; set; }
public virtual ICollection<DatabaseModel> Databases { get; set; }
}
그리고 내 상황 :
public async Task<IdentityResult> RegisterUser(UserModel user) {
user.Email = user.UserName;
var result = await _userManager.CreateAsync(user);
return result;
}
내가 얻을 : 이제
using MyMvcSite.Models;
namespace MyMvcSite.Web {
public class AuthContext : IdentityDbContext<UserModel> {
public AuthContext() : base("AuthContext") {
}
}
}
, 나는 사용자를 등록하는 코드를 실행할 때 오류 : The entity type IdentityUser is not part of the model for the current context.
내가보기에이 오류가 의미하는 바를 알 수 없습니다. 나는 모든 것이 정확하다. 아무도 잘못 될 수 있다고 말할 수 있습니까 ???
이전에 사용했기 때문에 연결 문자열 AuthContext
이 정확한지 확인합니다.
은 어떻게 당신의'_userManager'와는'context'의 인스턴스를합니까? 이것은 도움이 될 것 같습니다 : http://stackoverflow.com/questions/23893710/the-entity-type-applicationuser-is-not-part-of-the-model-for-the-current-context –
내'_userManager '는 다음과 같이 초기화되었습니다 :'_userManager = new UserManager (새로운 UserStore (_ ctx));'. 나는 그것을 '_userManager = new UserManager (새로운 사용자 저장소 (_ctx));로 변경하여 해결했습니다! 답변을 올리면 받아 들일 것입니다. 저를 올바른 방향으로 가리켜 주셔서 감사합니다! –
Brett