简体   繁体   English

System.Data.Entity.Core.MetadataException:'指定的架构无效。

[英]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.

相关问题 System.Data.Entity.Core.MetadataException:指定的架构无效 - System.Data.Entity.Core.MetadataException: Schema specified is not valid “ MetadataException,指定的架构无效” - “MetadataException, Schema specified is not valid” 指定的 EntityFramework 架构无效。 错误: - EntityFramework Schema specified is not valid. Errors: System.InvalidCastException:&#39;指定的强制转换无效。 - System.InvalidCastException: 'Specified cast is not valid.' System.Data.MetadataException:无法加载指定的元数据资源 - System.Data.MetadataException: Unable to load the specified metadata resource Xamarin 表单与 Firebase。 数据检索抛出 System.InvalidCastException: &#39;指定的转换无效。&#39; - Xamarin Forms with Firebase. Data retrival throwing System.InvalidCastException: 'Specified cast is not valid.' 指定的架构无效。 错误:未加载关系,因为类型不可用 - Schema specified is not valid. Errors: The relationship was not loaded because the type is not available 指定的架构无效。 错误:同名的多种类型 - Schema specified is not valid. Errors: Multiple types with the name System.InvalidCastException:指定的强制转换无效。错误 - System.InvalidCastException: Specified cast is not valid. Error Xamarin 形式:System.InvalidCastException:“指定的强制转换无效。” - Xamarin forms: System.InvalidCastException: 'Specified cast is not valid.'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM