user137348
user137348

Reputation: 10332

Entity Code first - required decimal

I'm using the modelBuilder class. Setting a not null field is easy using IsRequired when the property is of type string. As soon as the type is of type decimal, intellisense is not showing the IsRequired method.

  public class CategotyConfig: EntityConfiguration<Category>
  {
        public CategotyConfig()
        {
            this.Property(x => x.Name).IsRequired();
        }
  }

How can I set a field of type decimal to be not null ? Without using attributes.

Upvotes: 1

Views: 351

Answers (1)

Craig Stuntz
Craig Stuntz

Reputation: 126577

decimal (as opposed to decimal?) is already required, because it's non-nullable.

Upvotes: 2

Related Questions