Create the following database model using Entity Framework and Code First:
erDiagram User ||--o{ RegularUser : "is a" User ||--o{ Staff : "is a" Author ||--o{ Book : has Book }o--|| Genre : "belongs to" Borrowing }o--|| Staff : "borrowed by" Borrowing }o--|| Book : lends Purchase }o--|| RegularUser : "made by" Purchase }o--|| Staff : "sold by" Purchase }o--|| Book : sold Author { int AuthorID PK string Name DatiTime Birthdate } Book { string ISBN PK string Title int PublicationYear int NrOfCopiesAvailable } Genre { int GenreID PK string Name } User { int UserID PK string Username string Email } Staff { int UserID PK string StaffNr string Department } RegularUser { int UserID PK string CustomerNr } Borrowing { int BorrowingID PK DateTime ReturnBy } Purchase { int PurchaseID PK double Amount }
Notice, that the relationship between User, RegularUser and Staff is a Joined-Table Inheritance.
Use Constraints, such as [Required] where you think it’s useful.
After you are done generating the database, verify the schema, for example by using DataGrip to generate a database from the current schema and compare it to the schema, given above.