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

  • Home
  • SEARCH
  • 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 9234145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:43:15+00:00 2026-06-18T06:43:15+00:00

In my current web project I’m trying to set up code migrations. I set

  • 0

In my current web project I’m trying to set up code migrations. I set up my db initialiser as follows in my MVC4 project

protected void Application_Start()
{
    Database.SetInitializer(new MigrateDatabaseToLatestVersion<MyContext, Configuration>());
}

I can make changes to my code first models and this updates the database to the latest automatic migration as expected when I start up the website.

However I’m trying to add an explicit migration through the console Add-Migration FirstMigration so I can add some indexes. This adds the code file 201301071708126_FirstMigration to my project and I can add in my index code here easily enough.

But this won’t run automatically when I restart the website. I have to run Update-Database from the console to apply this migration.

I followed this tutorial on msdn but I can’t see what I’m doing wrong as it suggests to me that the explicit migration should run automatically.

In my configuration file I have the following constructor

public Configuration()
{
    AutomaticMigrationsEnabled = true;
    AutomaticMigrationDataLossAllowed = true;
}
  • 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-18T06:43:16+00:00Added an answer on June 18, 2026 at 6:43 am

    I found the answer to this a little while ago and I missed out some information in the question.

    I have 2 websites, an MVC app and a WEBAPI app. I need to have the database initialisation in both otherwise it doesn’t work properly.

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

Sidebar

Related Questions

I am using a web browser in my current project and currently I'm using
I have a project involving a web voting system. The current values and related
This is my sample code: SPWeb web = SPContext.Current.Web SPList list = web.Lists[TestList]; try
I'm on a current web project, on which there's a working PHPBB3 installation in
I have the following web.config file that contain the code as follows: <connectionStrings> <add
In a current web project, I'm using several jQuery plugins and initializing them just
I was just thinking about the URLs of my current web project. The user
I'm hoping to use jqGrid for a current web project that I'm working on.
I am trying to build a complicated web project that involves 4 websites that
I'm trying to get a current web application running on my local machine, for

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.