Reputation: 4410
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
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