代码之家  ›  专栏  ›  技术社区  ›  Brian J. Hakim

实体框架时间戳生成数据库问题

  •  9
  • Brian J. Hakim  · 技术社区  · 16 年前

    我对EF4.0有问题

    在SQL脚本中,列看起来像“binary(8)”,而不是timestamp。

    1 回复  |  直到 12 年前
        1
  •  12
  •   Brian J. Hakim    16 年前

    问题解决了:ef4不能从edmx设计器生成时间戳列。 解决方案很简单:

    1. 将类型设置为二进制。
    2. 将StoreGeneratedPattern设置为Computed。
    3. 将ConcurrencyMode设置为Fixed。
    4. 编辑一行(目前是151),上面写着:

    [<#=Id(属性名称)#>]<#=属性ToStoreType()#><#=写入实体(prop,targetVersion)#><#=WriteNullable(prop.Nullable)#><#=(p<entitySet.ElementType.Properties.Count-1)?“,”:“”#&燃气轮机;

    1. 更改为:

    [<#=Id(属性名称)#>]<#if(string.Compare(prop.Name,“TimeStamp”,true)==0{;时间戳<#}否则{#><#=属性ToStoreType()#><#}#&燃气轮机<#=写入实体(prop,targetVersion)#><#=WriteNullable(prop.Nullable)#><#=(p<entitySet.ElementType.Properties.Count-1)?“,”:“”#&燃气轮机;