Skip to content

Instantly share code, notes, and snippets.

@johnmmoss
Created June 30, 2020 20:52
Show Gist options
  • Save johnmmoss/1b8799bb8637d23c014d773781ec2691 to your computer and use it in GitHub Desktop.
Save johnmmoss/1b8799bb8637d23c014d773781ec2691 to your computer and use it in GitHub Desktop.
public class AcmeContext : DbContext
{
public AcmeContext(DbContextOptions<AcmeContext> options)
: base(options)
{
}
public DbSet<Employee> Employees { get; set; }
}
public class Employee
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int EmployeeID { get; set; }
[Column(TypeName = "date")]
public DateTime BirthDate { get; set; }
[StringLength(8)]
public string Title { get; set; }
[Required]
[StringLength(50)]
public string FirstName { get; set; }
[Required]
[StringLength(50)]
public string LastName { get; set; }
[Range(1, int.MaxValue, ErrorMessage = "Please select a valid Department")]
public int DepartmentID { get; set; }
public Department Department { get; set; }
}
public class Department
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int DepartmentID { get; set; }
[Required]
[StringLength(50)]
public string Name { get; set; }
[Required]
[StringLength(50)]
public string GroupName { get; set; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment