Created
June 30, 2020 20:52
-
-
Save johnmmoss/1b8799bb8637d23c014d773781ec2691 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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