gpt4 book ai didi

database - Entity Framework 时间戳生成数据库问题

转载 作者:太空狗 更新时间:2023-10-30 01:44:48 26 4
gpt4 key购买 nike

我遇到了 EF 4.0 的问题我用“时间戳”列创建实体。之后,我尝试生成数据库。

在 SQL 脚本中,列看起来像 'binary(8)' 而不是时间戳。

如何解决?

最佳答案

问题已解决:EF 4 无法从 edmx 设计器生成时间戳列。解决方案很简单:

  1. 将类型设置为二进制。
  2. 将 nullable 设置为 false。
  3. 将 StoreGeneratedPattern 设置为 Computed。
  4. 将 ConcurrencyMode 设置为 Fixed。
  5. 创建 SSDLToSQL10.tt 的副本(通常位于 C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Extensions\Microsoft\Entity Framework Tools\DBGen)。我们称它为 MySSDLToSQL10.tt。
  6. 编辑以下行(当前为 151):

[<#=Id(prop.Name)#>] <#=prop.ToStoreType()#> <#=WriteIdentity(prop, targetVersion)#> <#=WriteNullable(prop.Nullable)#><# =(p < entitySet.ElementType.Properties.Count - 1)? ",":""#>

  1. 将其更改为:

[<#=Id(prop.Name)#>] <#if (string.Compare(prop.Name,"TimeStamp",true) == 0) { #>timestamp<# } else { #>< #=prop.ToStoreType()#><# } #> <#=WriteIdentity(prop, targetVersion)#> <#=WriteNullable(prop.Nullable)#><#=(p < entitySet.ElementType.Properties.Count - 1)? ",":""#>

关于database - Entity Framework 时间戳生成数据库问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3184174/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com