Entity Framework 4.1 Fluent API 属性

Posted

技术标签:

【中文标题】Entity Framework 4.1 Fluent API 属性【英文标题】:Entity Framework 4.1 Fluent API property 【发布时间】:2011-06-09 16:40:17 【问题描述】:

配置属性时(Name为String,RowVersion为Byte)

这行得通:

Me.Property(Function(t) t.Name).IsRequired().IsFixedLength.HasMaxLength(10)

但这给了我一个错误:

Me.Property(Function(t) t.RowVersion).IsRequired().IsFixedLength().HasMaxLength(8)

错误是:

'IsFixedLength' 不是 'System.Data.Entity.ModelConfiguration.Configuration.PrimitivePropertyConfiguration'

有什么建议吗?

【问题讨论】:

【参考方案1】:

Because it isn't. 您可以在字符串上调用IsFixedLength(),但不能在TIMESTAMP 上调用。 HasMaxLength() 同上。无论如何,您希望 DB 对这样的配置做什么?

【讨论】:

以上是关于Entity Framework 4.1 Fluent API 属性的主要内容,如果未能解决你的问题,请参考以下文章

Entity Framework 4.1 InverseProperty 属性和ForeignKey

Entity Framework 4.1 Fluent API 属性

卸载 Entity Framework 4.1 六月 CTP

通过 Entity Framework 4.1 中的用户定义函数进行热切加载

Entity Framework 4.1 - 映射错误的模式

Entity Framework 4.1 - 非键列之间的关系