Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8885417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:18:24+00:00 2026-06-14T21:18:24+00:00

I was wondering (and I hate using the words ‘Best Practice’) – but is

  • 0

I was wondering (and I hate using the words ‘Best Practice’) – but is this a good way to approach configuration as it encapsulates the config for AAA?

I see a lot of examples where the OnModelCreating is a huge list of instructions for creating the database and long methods tell me something isn’t quiet right.

public class MyContext : DbContext
{
    public MyContext() : base("name=MyDb") { }

    public DbSet<AAA> AAAs { get; set; }

    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
        modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
        modelBuilder.Configurations.Add(new AAA.Configuration());
    }
}

And the class with a spot for it’s config

public class AAA
{
    [Key] 
    public int Id { get; set; }

    [Required] 
    public string Details { get; set; }

    internal class Configuration : EntityTypeConfiguration<AAA>
    {
        public Configuration()
        {
            // Set all the funky stuff here
        }
    }
}

I get that there probably isn’t one right way. Before I commit a lot of time and tears I am looking for a reason why this might be absolutely the worst idea in the world or if there is a way to do something similar?

EDIT

A Colleague suggested this as an alternate method using a static property

public class AAA
{
    [Key] 
    public int Id { get; set; }

    [Required] 
    public string Details { get; set; }

    public static EntityTypeConfiguration<AAA> Configuration
    {
        get { return new AAAConfiguration(); }
    }

}

internal class AAAConfiguration : EntityTypeConfiguration<AAA>
{
   public AAAConfiguration()
   {
            // Set all the funky stuff here
   }
}

I like this as it gives me a bit more flexibility with how the configuration is instanced.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T21:18:26+00:00Added an answer on June 14, 2026 at 9:18 pm

    It depends. I am by now far enough to say that I don’t care about db generation. It is nice and has advantages (platform independent) which I do not care about. it is limiting from using SQL Server fully – so it is back to database projects.

    This is a world of compromises, and – sorry- a best practice comes with a TON of limitations there.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Wondering what the best / good way of doing this would be in jQuery.
Wondering if there is a good way to generate temporary URLs that expire in
Wondering if anyone has a good solution for this. My app is displaying nothing
As a corollary to this question I was wondering if there was good comparative
Wondering if there is any way to get the lambda expressions that result from
Wondering what is the best or most popular database client tool. Similar to Microsoft's
Wondering if anyone can suggest a good file replication tool that will replicate across
wondering if some of you know what javascript framework facebook is using ? Thanks
Im just wondering how good the MSVC++ Compiler can optimize code(with Code examples) or
I was wondering if there is a shorter way of writing the following code:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.