starting assig6
This commit is contained in:
30
Ass6/Data/ApplicationDbContext.cs
Normal file
30
Ass6/Data/ApplicationDbContext.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Example.Models;
|
||||
|
||||
namespace Example.Data;
|
||||
|
||||
public class ApplicationDbContext : IdentityDbContext
|
||||
{
|
||||
public ApplicationDbContext(DbContextOptions options)
|
||||
: base(options)
|
||||
{
|
||||
}
|
||||
|
||||
public DbSet<Author> Authors => Set<Author>();
|
||||
public DbSet<Book> Books => Set<Book>();
|
||||
public DbSet<Review> Reviews => Set<Review>();
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder builder)
|
||||
{
|
||||
base.OnModelCreating(builder);
|
||||
|
||||
builder.Entity<Author>()
|
||||
.Property(author => author.Birthdate)
|
||||
.HasColumnType("date");
|
||||
|
||||
builder.Entity<Book>()
|
||||
.Property(book => book.Published)
|
||||
.HasColumnType("date");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user