【发布时间】:2017-07-29 18:00:52
【问题描述】:
我想将 Notification 类的 Gig 属性上的 [Required] 属性替换为以下流畅的 api 表达式。
public class NotificationConfiguration : EntityTypeConfiguration<Notification>
{
public NotificationConfiguration()
{
Property(n => n.Gig).IsRequired();
}
}
如果这样做,编译器会抛出错误 CS0453:
The type 'Gig' must be a non-nullable value type in order to use it as parameter 'T' in the generic type or method 'StructuralTypeConfiguration'<Notification>.Property<T>(Expression<Func<Notification, T>>)'
我看不出原因,为什么这不起作用。
谢谢!
【问题讨论】:
标签: api entity-framework-6 fluent