새 사용자가 등록하려고 할 때 사용자 이름이 이미 데이터베이스에 있는지 확인할 수 있도록 내 데이터베이스에서 모든 사용자 이름을 가져 오려고합니다.linq 식으로 데이터베이스에서 데이터를 가져올 수 없습니다.
[AllowAnonymous]
public ActionResult Register()
{
var q = from t in _db.User
select t;
return View();
}
을하지만 난 그것을 debugg 때 q는 "어린이가 평가 될 수 없습니다"가된다 : 임은이 LINQ 표현이 작업을 수행하려고합니다. 왜 내가이 오류가 발생하는지 모르겠다. 그래서 나는 그걸로 할 수 있다고 생각하는 것들을 게시한다. 여기
FantasySport _db = new FantasySport();
과 fantasysport 데이터베이스 모델 :
이 내가 등록 방법 위에 _db 정의하는 방법이다
[Table("UserProfile")]
public class UserProfile
{
[Key]
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
public int UserId { get; set; }
public string UserName { get; set; }
public string Firstname { get; set; }
public string Lastname { get; set; }
public string Country { get; set; }
public string City { get; set; }
public int Birthdate { get; set; }
public ICollection<Team> teams { get; set; }
}
: 여기
public class FantasySport : DbContext
{
public DbSet<UserProfile> User { get; set; }
public DbSet<Team> Team { get; set; }
public DbSet<TeamPlayer> TeamPlayer { get; set; }
public DbSet<Player> Player { get; set; }
public DbSet<Games> Games { get; set; }
public DbSet<League> League { get; set; }
}
그리고는 USERPROFILE 모델입니다
받고있는 예외 (그리고 정확한 예외 메시지 및 예외 유형)의 스택 추적을 게시 할 수 있습니까? – Slauma
요청한 데이터로 내 질문에 그림을 추가했습니다. –
이것은 의도 된 동작입니다. https://entityframework.codeplex.com/workitem/1995. 그 이유는 스레딩 및 디버깅을 통한 부작용 방지와 관련이 있습니다. –