作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
[Table( "User" )]
public class User
{
[Key]
[DatabaseGeneratedAttribute( DatabaseGeneratedOption.Identity )]
public ulong Id { get; set; }
// other columns
}
对于这段代码,我得到了异常:
System.Data.Entity.Edm.EdmEntityType: : EntityType 'User' has no key defined. Define the key for this EntityType.
但是将 Id 的类型更改为 int,一切正常。
//...
[DatabaseGeneratedAttribute( DatabaseGeneratedOption.Identity )]
public int Id { get; set; }
//...
如何获得使用具有 ulong 类型容量的 Id 自动创建表的可能性? (显然首先使用 ef 的代码)
最佳答案
鉴于数字 sql server 类型是:
bigint, numeric, bit, smallint, decimal, smallmoney, int, tinyint, money
很明显,CLR 类型 UInt64
(ulong
) 不映射到任何这些类型。
关于c# - EF 的 DatabaseGeneratedOption.Identity 属性不适用于 ulong 类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25853864/
我是一名优秀的程序员,十分优秀!