Nils Anders
Nils Anders

Reputation: 4410

EntityTypeConfiguration in Entity Framework 6 RC1

Is there any reason to specify all the columns in each table like this

this.HasKey(t => t.EmployeeID);

            // Properties
            this.Property(t => t.LastName)
                .IsRequired()
                .HasMaxLength(20);

And if is it, why?

Upvotes: 1

Views: 357

Answers (1)

user247702
user247702

Reputation: 24202

If you're asking if there's another way to specify not null and nvarchar(n), you can also use attributes from the System.ComponentModel.DataAnnotations namespace.

public class Employee
{
    [Key]
    public int EmployeeID { get; set; }

    [Required]
    [MaxLength(20)]
    public string LastName { get; set; }
}

Upvotes: 2

Related Questions