在我的DbContext
课上,我有以下内容:
void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Properties<string>().Configure(c => { c.HasMaxLength(250); });
}
而且也在我拥有的特定模型的EntityTypeConfiguration
类内部:
{
Property(p => p.Name).HasMaxLength(500);
}
问题是,在Configuration类中将属性设置为500无效,并且EF仍在验证最大值为250。
我如何将常规设置设置为250,但需要在每个类中使用流利的api覆盖?
@@ Lutti Coelho:我的错
在下面的OnModelCreating方法中添加代码
modelBuilder.Entity<Student>()
.Property(p => p.StudentName)
.HasMaxLength(50);