Created
August 25, 2019 23:09
-
-
Save sametoz/56c2bf07c1f832598a989d86d1d8d066 to your computer and use it in GitHub Desktop.
code-first database design
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
using System; | |
using System.Collections.Generic; | |
using System.ComponentModel.DataAnnotations; | |
namespace RentACar.Models | |
{ | |
public class Car | |
{ | |
public int CarID { get; set; } | |
public string Brand { get; set; } | |
public string Model { get; set; } | |
public int Detail { get; set; } | |
public ICollection<Rent> Rents { get; set; } | |
} | |
public class Customer | |
{ | |
public int CustomerID { get; set; } | |
public string FullName { get; set; } | |
[Required] | |
public int NationID { get; set; } | |
public string Adress { get; set; } | |
public ICollection<Rent> Rents { get; set; } | |
public ICollection<Reservation> Reservations { get; set; } | |
} | |
public class Branch | |
{ | |
public int BranchID { get; set; } | |
public string Adress { get; set; } | |
public City City { get; set; } | |
[ForeignKey("City")] | |
public int CityFK { get; set; } | |
} | |
public class City | |
{ | |
public int CityID {get;set;} | |
public string Name {get;set; | |
public ICollection<Branch> Branches { get; set; } | |
} | |
public class Rent | |
{ | |
public int RentID { get; set; } | |
public int TakeBranchId { get; set; } | |
public int LeaveBranchId { get; set; } | |
public DateTime StartDate {get;set;} | |
public DateTime EndDate {get;set;} | |
[ForeignKey("Customer")] | |
public int CustomerFK { get; set; } | |
[ForeignKey("Car")] | |
public int CarFK { get; set; } | |
[ForeignKey("TakeBranchId")] | |
public virtual Branch TakeBranch { get; set; } | |
[ForeignKey("LeaveBranchId")] | |
public virtual Branch LeaveBranch { get; set; } | |
} | |
public class Reservation | |
{ | |
public int ReservationID { get; set; } | |
public int TakeBranchId { get; set; } | |
public int LeaveBranchId { get; set; } | |
[ForeignKey("TakeBranchId")] | |
public virtual Branch TakeBranch { get; set; } | |
[ForeignKey("LeaveBranchId")] | |
public virtual Branch LeaveBranch { get; set; } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment