C# 如何更新实体

C# 如何更新实体,c#,entity-framework,entity-framework-4,C#,Entity Framework,Entity Framework 4,我插入要列出并保存的对象 桌子(int自动识别), varchar(名称) //desk.id==0 我需要把身份证拿到桌子上。如何做到这一点 属性id: /// <summary> /// No Metadata Documentation available. /// </summary> [EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)] [Da

我插入要列出并保存的对象

桌子(int自动识别), varchar(名称)

//desk.id==0

我需要把身份证拿到桌子上。如何做到这一点

属性id:

/// <summary>
    /// No Metadata Documentation available.
    /// </summary>
    [EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)]
    [DataMemberAttribute()]
    public global::System.Int32 id
    {
        get
        {
            return _id;
        }
        set
        {
            if (_id != value)
            {
                OnidChanging(value);
                ReportPropertyChanging("id");
                _id = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("id");
                OnidChanged();
            }
        }
    }
    private global::System.Int32 _id;
    partial void OnidChanging(global::System.Int32 value);
    partial void OnidChanged();
//
///没有可用的元数据文档。
/// 
[EdmScalarPropertyAttribute(EntityKeyProperty=true,IsNullable=false)]
[DataMemberAttribute()]
公共全局::System.Int32 id
{
得到
{
返回_id;
}
设置
{
如果(_id!=值)
{
onidchange(值);
报告财产变更(“id”);
_id=StructuralObject.SetValidValue(值);
ReportPropertyChanged(“id”);
OnidChanged();
}
}
}
私有全局::System.Int32_id;
部分无效OnidChange(全局::System.Int32值);
部分无效OnidChanged();
edmx:



提交后查看
桌面.ID
属性=>将从数据库中为其分配新值。

提交后查看
桌面.ID
属性=>将从数据库中为其分配新值。

是用
StoreGeneratedPattern.Identity定义的实体模型中的
ID
(检查EDMX文件中
Id
属性的属性)?我更新post。不存在StoreGeneratedPattern.Identity。是否在实体模型中使用
StoreGeneratedPattern.Identity
(检查EDMX文件中
Id
属性)?我更新post。不存在StoreGeneratedPattern.Identity。
/// <summary>
    /// No Metadata Documentation available.
    /// </summary>
    [EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)]
    [DataMemberAttribute()]
    public global::System.Int32 id
    {
        get
        {
            return _id;
        }
        set
        {
            if (_id != value)
            {
                OnidChanging(value);
                ReportPropertyChanging("id");
                _id = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("id");
                OnidChanged();
            }
        }
    }
    private global::System.Int32 _id;
    partial void OnidChanging(global::System.Int32 value);
    partial void OnidChanged();
 <EntityType Name="Desk">
          <Key>
            <PropertyRef Name="id" />
          </Key>
          <Property Name="id" Type="int" Nullable="false" StoreGeneratedPattern="Identity" />
          <Property Name="width" Type="float" Nullable="false" />
          <Property Name="height" Type="float" Nullable="false" />
          <Property Name="x" Type="int" Nullable="false" />
          <Property Name="y" Type="int" Nullable="false" />
          <Property Name="countMax" Type="int" Nullable="false" />
          <Property Name="countReal" Type="int" />
          <Property Name="date" Type="datetime" />
          <Property Name="id_status" Type="int" Nullable="false" />
        </EntityType>