DEV Community

Mahir Xalilov
Mahir Xalilov

Posted on

DBcontext

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);
}
Enter fullscreen mode Exit fullscreen mode

}

Top comments (0)