mirror of
https://github.com/QuotifyTeam/QuotifyBE.git
synced 2025-12-16 19:00:07 +01:00
feat: basic database model
This commit is contained in:
29
Data/ApplicationDbContext.cs
Normal file
29
Data/ApplicationDbContext.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
// using Microsoft.AspNetCore.Identity;
|
||||
// using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using QuotifyBE.Entities;
|
||||
|
||||
namespace QuotifyBE.Data
|
||||
{
|
||||
public class ApplicationDbContext : DbContext //<User, IdentityRole<string>, string>
|
||||
{
|
||||
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
|
||||
: base(options)
|
||||
{
|
||||
}
|
||||
|
||||
public DbSet<User> Users => Set<User>();
|
||||
public DbSet<Quote> Quotes => Set<Quote>();
|
||||
public DbSet<Category> Categories => Set<Category>();
|
||||
public DbSet<Image> Images => Set<Image>();
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder builder)
|
||||
{
|
||||
base.OnModelCreating(builder);
|
||||
|
||||
builder.Entity<QuoteCategory>()
|
||||
.HasKey(vs => new { vs.QuoteId, vs.CategoryId });
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user