“Execute Code First Migrations” checkbox disappeared from my publish profile

前端 未结 6 699
逝去的感伤
逝去的感伤 2020-12-15 23:17

I\'m using web deploy to deploy an MVC4 application using EF5 code first. I made a publish profile called \"development\" that uses web deploy for application and database u

相关标签:
6条回答
  • 2020-12-15 23:51

    Just to add to the mix, don't call your Connection Class DbConn didn't seem to like that.

    0 讨论(0)
  • 2020-12-15 23:55

    Since nothing mentioned above worked.
    I downloaded the publish profile from azure and it worked flawlessly the first time

    0 讨论(0)
  • 2020-12-16 00:01

    Here is the right answer - is solved the problem for me. Just rename your connection string exactly as your DbContext, e.g.

            public ApplicationDbContext()
            : base("Vocabulary.Domain.ApplicationDbContext", throwIfV1Schema: false)
        {
        }
    

    Note that name should include namespace like "Vocabulary.Domain.ApplicationDbContext". Don't forget to update .pubxml files:

        <ObjectGroup Name="Vocabulary.Domain.ApplicationDbContext" Order="1" Enabled="True">
    

    This article describes when publish dialog has or has no the tick "Execute Code First Migrations (runs on application start)"

    0 讨论(0)
  • 2020-12-16 00:14

    I had this problem and for me it had a different cause to any I've found documented elsewhere.

    My application is spread over many projects in a solution. As I use interfaces and a separate View/Presentation model to wrap calls to the database, my front web project had no direct reference to the project containing the DbContext class. Note that this posed no problem to my running the site locally. I do this so that developers in the front end web project are not tempted to bypass the Presentation layer and go more directly to the database.

    Adding this reference immediately fixed the problem and now I see the 'Execute Code First Migrations' checkbox in my Publish Profile dialog.

    0 讨论(0)
  • 2020-12-16 00:15

    Since asking this question, I've run into this problem several more times in multiple versions of MVC and EF (all code first though of cource). When it happens, don't save the changes to your publish profile, make sure you are on the 'debug' build configuration, clean solution and rebuild solution. And if all that fails, restart Visual Studio and try again. So far, this has always solved the problem for me.

    0 讨论(0)
  • 2020-12-16 00:18

    This happened to me in VS2013. Neither cleaning the solution, nor restarting it worked. I tried to "re-enable" migrations and it worked. Even though I got an error message that migrations have already been enabled in project, the "Execute Code First Migrations" checkbox appeared again.

    0 讨论(0)
提交回复
热议问题