July 15 2025

public partial class BlogDbContext : DbContext { public BlogDbContext(DbContextOptions<BlogDbContext> options) : base(options) { OnCreated(); } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { if (!optionsBuilder.IsConfigured || (!optionsBuilder.Options.Extensions.OfType<RelationalOptionsExtension>().Any(ext => !string.IsNullOrEmpty(ext.ConnectionString) || ext.Connection != null) && !optionsBuilder.Options.Extensions.Any(ext => !(ext is RelationalOptionsExtension) && !(ext is CoreOptionsExtension)))) { } CustomizeConfiguration(ref optionsBuilder); base.OnConfiguring(optionsBuilder); } public virtual DbSet<Blog> Blogs { get; set; } public virtual DbSet<Post> Posts { get; set; } public virtual DbSet<Comment> Comments { get; set; } protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); this.BlogMapping(modelBuilder); this.CustomizeBlogMapping(modelBuilder); this.PostMapping(modelBuilder); this.CustomizePostMapping(modelBuilder); this.CommentMapping(modelBuilder); this.CustomizeCommentMapping(modelBuilder); RelationshipsMapping(modelBuilder); CustomizeMapping(ref modelBuilder); } ... }
public partial class Blog { public Blog() { this.Posts = new List<Post>(); OnCreated(); } public Guid ID { get; set; } public string Title { get; set; } public string Description { get; set; } public DateTime CreatedAt { get; set; } public virtual IList<Post> Posts { get; set; } #region Extensibility Method Definitions partial void OnCreated(); #endregion }

1. Design Patterns that Deliver
This isnât just another design patterns book. Dive into real-world examples and practical solutions to real problems in real applications.Check out it here.
Go-to resource for understanding the core concepts of design patterns without the overwhelming complexity. In this concise and affordable ebook, I've distilled the essence of design patterns into an easy-to-digest format. It is a Beginner level. Check out it here.
Every Monday morning, I share 1 actionable tip on C#, .NET & Arcitecture topic, that you can use right away.
Join 18,000+ subscribers to improve your .NET Knowledge.
Subscribe to the TheCodeMan.net and be among the 18,000+ subscribers gaining practical tips and resources to enhance your .NET expertise.