【发布时间】:2015-04-23 09:43:07
【问题描述】:
我正在使用存储库模式。我有一个名为 Product 的实体,我想设置价格的最小值以避免零价格。是否可以在 EntitytypeConfiguration 类中创建它?
我的产品配置类
public class ProductConfiguration : EntityTypeConfiguration<Product>
{
public PlanProductConfiguration(string schema = "dbo")
{
ToTable(schema + ".Product");
HasKey(x => new { x.IdProduct });
Property(x => x.Price).HasColumnName("flt_price")
.IsRequired()
.HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
}
}
【问题讨论】:
-
不幸的是 Fluent API 仅支持 MaxLength
标签: c# entity-framework ef-code-first ef-fluent-api