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:驱动器。我不知道这是否可能导致了这个问题。 –