locked
Execute Code First Migrations flag disabled on Publishing App RRS feed

  • Question

  • User438705957 posted

    I've setup an Azure account (free trial) and am attempting to publish my Code First app.
    I have enabled migrations for my context and ran update-database with no problems.
    The initialization code in my configuration.cs file ran to completion and populated the database.

    I am now attempting to publish my app to the web app and database I have setup thru my Azure acocunt.

    The issue I am having is that the flag to Execute Code First Migrations is disabled.

    I know I am having problems connecting to the Azure site/database because the "Validate Connection" fails. This is another drama altogether.
    I am not sure if this is why the flag is disabled.

    Thanks for considering.

    Tuesday, March 20, 2018 3:32 AM

All replies

  • User283571144 posted

    Hi Madog,

    According to your description, I guess you may see below image:

    This is potentially because either you do not full code written for Code migration in your application as well no or incorrect DB setup in your web.config .

    In order to have Code Migration enabled, you must have a DB configured (in case of Windows Azure you need to provide SQL Database info in the web.config) in web.config and a complete class is written on how the code migration will happen depend on your model. 

    I suggest you could try to open the nuget package console and run enable-migrations command, then it will work well.

    Like below image:

    Best Regards,

    Brando

    Wednesday, March 21, 2018 5:33 AM
  • User438705957 posted

    Thanks Brando,

    I have already enable migrations thru package manager console and have run the update-database command several times.

    My understanding is that the publishing process gets its Azure connection string info from the Azure subscription (web app and database)  supplied thru the publishing process.
    I am not aware you have to have the Azure connection set up in your web.config in development. Of course, I have my development database set up in web.config.

    Still confused.

    Wednesday, March 21, 2018 6:57 AM
  • User283571144 posted

    Hi Madog,

    My understanding is that the publishing process gets its Azure connection string info from the Azure subscription (web app and database)  supplied thru the publishing process.

    As far as I know, the publishing process will not get Azure connection string info from the Azure subscription.

    It will only check the connection string is exists or not.

    On my test demo, I used LocalDb as the connection string and it works well.

    I suggest you could try to delete the migration folder and rebuild the project. 

    Then enable migration again.

    Best Regards,

    Brando

    Friday, March 23, 2018 7:39 AM
  • User438705957 posted

    Thanks Brando,

    I have done all that and the box is still unselectable. I too have the context pointing to localDB.

    It is perhaps related to a failure I receive when trying to validate the Azure connection on the connection tab of the Publish Web page.

    I get an error Could not complete the request to the remote agent URL.......underlying connection was closed.
    I think I have to solve that error before proceeding.

    Monday, March 26, 2018 12:58 AM