diff options
Diffstat (limited to 'Models')
-rw-r--r-- | Models/Author.cs | 10 | ||||
-rw-r--r-- | Models/Book.cs | 13 | ||||
-rw-r--r-- | Models/LibraryContext.cs | 1 |
3 files changed, 16 insertions, 8 deletions
diff --git a/Models/Author.cs b/Models/Author.cs new file mode 100644 index 0000000..9f04a58 --- /dev/null +++ b/Models/Author.cs @@ -0,0 +1,10 @@ +namespace LibraryAPI.Models { + public class Author { + public long Id { get; set; } + public List<Book>? Books { get; set; } + public string? Country { get; set; } + public string? Name { get; set; } + public int YearOfBirth { get; set; } + public string[]? languages { get; set; } + } +}
\ No newline at end of file diff --git a/Models/Book.cs b/Models/Book.cs index bcf9ef7..29faa97 100644 --- a/Models/Book.cs +++ b/Models/Book.cs @@ -1,15 +1,12 @@ -using System.ComponentModel.DataAnnotations.Schema; -using System.ComponentModel.DataAnnotations; - namespace LibraryAPI.Models { public class Book { - [Key] - [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public long Id { get; set; } + public long AuthorId { get; set; } + public Author? Author { get; set; } public int PublicationYear { get; set; } - public string[] Genres { get; set; } + public string[]? Genres { get; set; } public int Edition { get; set; } - public string ISBN { get; set; } - public string Title { get; set; } + public string? ISBN { get; set; } + public string? Title { get; set; } } }
\ No newline at end of file diff --git a/Models/LibraryContext.cs b/Models/LibraryContext.cs index 114ce2c..5e31e8f 100644 --- a/Models/LibraryContext.cs +++ b/Models/LibraryContext.cs @@ -2,6 +2,7 @@ using Microsoft.EntityFrameworkCore; namespace LibraryAPI.Models { public class LibraryContext : DbContext { + public DbSet<Author>? Authors { get; set; } public DbSet<Book>? Books { get; set; } public LibraryContext(DbContextOptions<LibraryContext> options) : base(options) {} //protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) |