身份'的成员没有在元数据收集存在\ r \ n参数名:身份证 [英] The member with identity ' ' does not exist in the metadata collection.\r\nParameter name: identity

查看:397
本文介绍了身份'的成员没有在元数据收集存在\ r \ n参数名:身份证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我简化了codeA一会儿试图调试:

  [HttpPost]
    公众的ActionResult注册(用户模式)
    {
        日期时间BLA =新的日期时间(2012,12,12);
        尝试
        {
            用户的用户=新用户
            {
                GID = 1,
                CID = 1,
                的firstName = model.firstName,
                的lastName = model.lastName,
                电子邮件= model.email,
                用户名= model.username,
                密码= model.password,
                creationDate = BLA,
                激活= 1
            };
            myContext.Users.AddObject(用户);
            myContext.SaveChanges();

        }
        赶上(例外前)
        {
            抛出前;
        }

        返回查看();
    }
 

该值将相应上发射。用户表:

  [ID] [INT] IDENTITY(1,1)NOT NULL,
[CID] [INT] NULL,
[GID] [INT] NULL,
[名字] [为nvarchar(100)NOT NULL,
[姓氏] [为nvarchar(100)NOT NULL,
[邮件] [为nvarchar(最大值)NOT NULL,
[用户名] [为nvarchar(100)NOT NULL,
[密码] [为nvarchar(100)NOT NULL,
[creationDate] [日期时间] NOT NULL,
[活动] [INT] NOT NULL,
 

约束[PK_的用户的_3213E83F0AD2A005] PRIMARY KEY CLUSTERED

我删除了所有的外键,以确保没有任何影响的。我qute肯定的是,在previous时刻是工作,但现在我不明白的地方的问题。 它崩溃而执行的SaveChanges:

  {,同时更新条目时发生错误。详细信息请参见内部异常。}
{身份''的成员没有在元数据收集存在\ r \ n参数名:身份证}
 

解决方案

问题被复制,因为一个触发器,它是在用户表。删除它,问题没有重现了。

I simplified the code a little while trying to debug:

[HttpPost]
    public ActionResult Register(User model)
    {
        DateTime bla = new DateTime(2012, 12, 12);
        try
        {
            User user = new User
            {
                gid = 1,
                cid = 1,
                firstName = model.firstName,
                lastName = model.lastName,
                email = model.email,
                username = model.username,
                password = model.password,
                creationDate = bla,
                active = 1
            };
            myContext.Users.AddObject(user);
            myContext.SaveChanges();

        }
        catch (Exception ex)
        {
            throw ex;
        }

        return View();               
    }

The values are transmited accordingly. Users table:

[id] [int] IDENTITY(1,1) NOT NULL,
[cid] [int] NULL,
[gid] [int] NULL,
[firstName] [nvarchar](100) NOT NULL,
[lastName] [nvarchar](100) NOT NULL,
[email] [nvarchar](max) NOT NULL,
[username] [nvarchar](100) NOT NULL,
[password] [nvarchar](100) NOT NULL,
[creationDate] [datetime] NOT NULL,
[active] [int] NOT NULL,

CONSTRAINT [PK_Users_3213E83F0AD2A005] PRIMARY KEY CLUSTERED

I deleted all the foreign keys to be sure that nothing affects it. I am qute certain that at a previous moment it was working, but now I can not figure where the issue is. It crashes while performing the savechanges:

{"An error occurred while updating the entries. See the inner exception for details."}
{"The member with identity '' does not exist in the metadata collection.\r\nParameter name: identity"}

解决方案

The issue was reproducing because of a trigger that was on the users table. Removed it and the issue is not reproducing anymore.

这篇关于身份'的成员没有在元数据收集存在\ r \ n参数名:身份证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆