var user = db.Users.FirstOrDefault(u => u.Email.Equals(username) && u.Password.Equals(password));
錯誤:
Local = 'db.Users.Local' threw an exception of type 'System.InvalidOperationException'
詳細的錯誤信息:
Message = "The context cannot be used while the model is being created. This exception may be thrown if the context is used inside the OnModelCreating method or if the same context instance is accessed by multiple threads concurrently. Note that instance members of D... Source: ""entityframework" StackTrace:StackTrace = " at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()\r\n at System.Data.Entity.Internal.InternalContext.Initialize()\r\n at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)\r\n at System...
連接之前,你在哪裏把你的代碼?查詢沒什麼問題,但我猜你正在把它放在一個錯誤的地方。 – akazemis
副節點:將密碼存儲在數據庫中是不好的做法;存儲密碼的密碼哈希,最好是SALT。 – N8allan
事情是它工作正常,直到我將我的項目從我的文檔移動到c:驅動器。我不知道這是否可能導致了這個問題。 –