20 lines
589 B
C#
20 lines
589 B
C#
using LexWells.Infrastructure.EntityFramework;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using NewsArchival.Core.Models;
|
|
|
|
namespace NewsArchival.Api.Data;
|
|
|
|
public class AppDbContext(DbContextOptions<AppDbContext> options) : LexWellsDbContext(options)
|
|
{
|
|
public DbSet<Article> Articles => Set<Article>();
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
{
|
|
base.OnModelCreating(modelBuilder);
|
|
|
|
// Ensure we don't save the same URL twice
|
|
modelBuilder.Entity<Article>()
|
|
.HasIndex(a => a.Url)
|
|
.IsUnique();
|
|
}
|
|
} |