[英]System.Data.Entity.Core.MetadataException: 'Schema specified is not valid.
I'm creating a login window and problem appears when pressing submit button after entering wrong credentials. 我正在创建一个登录窗口,输入错误的凭据后按“提交”按钮时出现问题。 Here is my view
这是我的看法
@model ProjectyMcProjectface.Models.RegisteredUser
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Login page</title>
@Styles.Render("~/Content/LoginVisuals")
</head>
<body>
<div id="LoginWrapper">
@using (Html.BeginForm("Authorize", "Login",FormMethod.Post))
{
<table id="LoginTable">
<tr>
<td>@Html.LabelFor(model => model.UserName)</td>
<td>@Html.EditorFor(model => model.UserName)</td>
</tr>
<tr>
<td></td>
<td>@Html.ValidationMessageFor(model => model.UserName)</td>
</tr>
<tr>
<td>@Html.LabelFor(model => model.PassWord)</td>
<td>@Html.EditorFor(model => model.PassWord)</td>
</tr>
<tr>
<td></td>
<td>@Html.ValidationMessageFor(model => model.PassWord)</td>
</tr>
<tr>
<td colspan="2"><label class="field-validation-error">@Html.DisplayFor(model => model.LoginErrorMessage)</label></td>
</tr>
<tr>
<td></td>
<td>
<input type="submit" value="Login" />
<input type="reset" value="Clear" />
</td>
</tr>
</table>
}
</div>
@Scripts.Render("~/bundles/ValidationScripts")
</body>
</html>
my registered user model 我的注册用户模型
public partial class RegisteredUser
{
public int Id { get; set; }
[DisplayName("User Name")]
[Required(ErrorMessage = "This field is required to be filled")]
public string UserName { get; set; }
[DataType(DataType.Password)]
[DisplayName("Password")]
[Required(ErrorMessage = "This field is required to be filled")]
public string PassWord { get; set; }
public string LoginErrorMessage { get; set; }
}
and my login controller 和我的登录控制器
[HttpPost]
public ActionResult Authorize(ProjectyMcProjectface.Models.RegisteredUser userModel)
{
using (InternalDBEntities1 db = new InternalDBEntities1())
{
var userDetails = db.RegisteredUsers.Where(x => x.UserName == userModel.UserName && x.PassWord == userModel.PassWord).FirstOrDefault();
if (userDetails == null)
{
userModel.LoginErrorMessage = "Your password or user name is incorrect";
return View("Index", "Login", userModel);
}
}
return View();
}
the error fires in line 错误触发
var userDetails = db.RegisteredUsers.Where(x => x.UserName == userModel.UserName && x.PassWord == userModel.PassWord).FirstOrDefault();
and says 并说
The mapping of CLR type to EDM type is ambiguous because multiple CLR types match the EDM type 'RegisteredUser'.
CLR类型到EDM类型的映射不明确,因为多个CLR类型与EDM类型“ RegisteredUser”匹配。 Previously found CLR type 'ProjectyMcProjectface.RegisteredUser', newly found CLR type 'ProjectyMcProjectface.Models.RegisteredUser'.'
以前发现CLR类型为'ProjectyMcProjectface.RegisteredUser',新发现CLR类型为'ProjectyMcProjectface.Models.RegisteredUser'。
How can I solve this? 我该如何解决?
It seems to be path of Edm has been changed some how. 似乎Edm的路径已经有所改变。 Please check the edm location whether it is ok and clean and rebuild the project
请检查edm位置是否正常,然后清理并重建项目
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.