Using EFCore with IdentityCore, after override OnModelCreating, you have to call base method to be able to create database for the first time
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<PostCategory>()
.HasKey(t => new { t.PostId, t.CategoryId });
modelBuilder.Entity<PostCategory>()
.HasOne(pt => pt.Post)
.WithMany(p => p.PostCategories)
.HasForeignKey(pt => pt.PostId);
modelBuilder.Entity<PostCategory>()
.HasOne(pt => pt.Category)
.WithMany(t => t.PostCategories)
.HasForeignKey(pt => pt.CategoryId);
base.OnModelCreating(modelBuilder);
}
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
Using EFCore with IdentityCore, after override OnModelCreating, you have to call base method to be able to create database for the first time
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.