none
EF Data Migration command generats empty SQL Scripts RRS feed

  • Question

  • Hi,

    I have a windows application where i want to generate the SQL scripts from a Datamigration file. The datamigration file i have taken from a different application. When  run EF datamigration command it is generating an empty script.

    I am getting this message:
    PM> Update-Database -Script -SourceMigration:$InitialDatabase -TargetMigration:"201310082048306_DocContent"
    Target database is already at version 201310082048306_DocContent.

    Please suggest.

    Advance Thanks,
    Bijay 

    Sunday, December 22, 2013 3:41 PM

Answers

  • Hello,

    >>PM> Update-Database -Script -SourceMigration:$InitialDatabase -TargetMigration:"201310082048306_DocContent"

    This command is used to migrate the database from initial version to the 201310082048306_DocContent version.

    >>Target database is already at version 201310082048306_DocContent.

    It shows that the database version has already been 201310082048306_DocContent version so it will do nothing about the migration and of course the script will be null.

    If we want to get the migration script from initial version to 201310082048306_DocContent version, we need to roll all the way back to an initial database then we can use the command as below:

    Update-Database –TargetMigration: $InitialDatabase.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, December 23, 2013 3:07 AM
    Moderator

All replies

  • Hello,

    >>PM> Update-Database -Script -SourceMigration:$InitialDatabase -TargetMigration:"201310082048306_DocContent"

    This command is used to migrate the database from initial version to the 201310082048306_DocContent version.

    >>Target database is already at version 201310082048306_DocContent.

    It shows that the database version has already been 201310082048306_DocContent version so it will do nothing about the migration and of course the script will be null.

    If we want to get the migration script from initial version to 201310082048306_DocContent version, we need to roll all the way back to an initial database then we can use the command as below:

    Update-Database –TargetMigration: $InitialDatabase.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, December 23, 2013 3:07 AM
    Moderator
  • Hi, Thanks for the quick reply. However if i am executing this command Update-Database –TargetMigration: $InitialDatabase Then it is generating the script for the Context class but not from the DataMigration file. We need to generate the SQL script from a DataMigratyion file. Which we have added to Migration folder. Please help. Thanks, Bijay
    Monday, December 23, 2013 2:02 PM
  • Hello,

    I mean that you can firstly drop the version to the initial version and then use the PM> Update-Database -Script -SourceMigration:$InitialDatabase -TargetMigration:"201310082048306_DocContent" command to generate the SQL script from a DataMigratyion file.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, December 24, 2013 5:49 AM
    Moderator
  • Hi,

    If you don't mind. Could you please let me know the command to drop the version to the initial version.

    Thanks,
    Bijay

    Tuesday, December 24, 2013 6:54 AM
  • Hi,

    >>Could you please let me know the command to drop the version to the initial version.

    It is Update-Database TargetMigration: $InitialDatabase which I have posted.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, December 24, 2013 6:56 AM
    Moderator