using System.Linq; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity.EntityFrameworkCore; using Microsoft.EntityFrameworkCore; using MyHN.Application; using MyHN.Domain; namespace MyHN.Infrastructure { public class MyHNDbContext : IdentityDbContext, IContext { public DbSet Links { get; set; } public DbSet Comments { get; set; } // IQueryable IContext.Links { get { return Links; } } IQueryable IContext.Links => Links; IQueryable IContext.Comments => Comments; IQueryable IContext.Users => Users; public MyHNDbContext() { } public MyHNDbContext(DbContextOptions options) : base(options) { } protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); // modelBuilder.ApplyConfiguration(new LinkEntityType()); // modelBuilder.Entity() // .Property(o => o.Url).IsRequired().HasMaxLength(255); modelBuilder.ApplyConfigurationsFromAssembly(GetType().Assembly); } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { if (!optionsBuilder.IsConfigured) { optionsBuilder.UseSqlite("Data Source=:memory:"); } } } }