public class AppDbContext:IdentityDbContext
{
public DbSet Places { get; set; }
public DbSet Categories { get; set; }
public AppDbContext(DbContextOptions opt):base(opt)
{
}
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
builder.Entity<Category>()
.HasMany(e => e.Places)
.WithOne(e => e.Category)
.HasForeignKey(e => e.CategoryId);
}
}
Top comments (0)