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 8137263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T11:03:33+00:00 2026-06-06T11:03:33+00:00

I have created two DbContexts, one is for application configuration, the second is for

  • 0

I have created two DbContexts, one is for application configuration, the second is for logging.

The reason being, I want to set a maximum size on the logging db so it doesn’t use up all free disk space and prevent other databases from working.

In my global.asax.cs file, I have the following:

        protected void Application_Start()
    {

        AreaRegistration.RegisterAllAreas();

        RegisterGlobalFilters(GlobalFilters.Filters);
        RegisterRoutes(RouteTable.Routes);

        Database.SetInitializer<AdminContext>(new AdminInitialiser());
        Database.SetInitializer<LoggingContext>(new LoggingInitialiser());
    }

The InitializeDatabase method in LoggingInitialiser is not being called. Is this because only one initializer can be set? Is there any way to have initializers for two DbContexts?

  • 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-06T11:03:35+00:00Added an answer on June 6, 2026 at 11:03 am

    Set the initializer in the DbContext constructor instead.

    public class AdminContext : DbContext
    {
        public AdminContext()
        {
            Database.SetInitializer(new AdminInitialiser());
        }
    }
    
    public class LoggingContext : DbContext
    {
        public LoggingContext()
        {
            Database.SetInitializer(new LoggingInitialiser());
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created two forms in my Windows Application. One Form acts as a
I have created two applications in my symfony project, but my second application i
I have created a web application in mvc3 and created two partial views one
I have created two WindowSurface (WPF), and I want to navigate betwen them. I've
I have created two folders layout and layout-land with two xml files, one for
I have created two JavaScript files. One file is "validators.js" and the other is
I have created two viewController classes such that one is superclass of another.i have
I have created two dictionaries in the user defaults of my application to represent
I have created two separate objects, one of class Order and one of class
I have created two layout files (in res/layout and res/layout-land) for my application. But

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.