none
update-database not updating new columns of a created table RRS feed

  • Question

  • Hello All,
    the first time I have ran add-migration [name], it worked like a charm and created a directory named Migration including all required files as well.

    After I updated my table class file and added a new column into it, I ran add-migration [newname] and it successfully created the file. In this new file, it attempts to re-create my tables again and it causes an error which is There is already an object named 'TableName' in the database.

    I have done a lot of googles, but nothing found except some manual codes.

    What I wanted to know is that, every time that I need to manage and update my tables, I need to edit the class file of migrations??????? It seems not easy and rational.

    Is there anyone facing this problem, or if there is a solution for this matter, I'd appreciate your helps.

    PS. Either update-database -verbose or add-migration [name] -ignorechanges are showing up with a RED ERROR that this command is not included Entity Framework.

    Please help.

    Sunday, July 17, 2016 11:32 AM

Answers

  • Hi, 

    If you need to update the database to reflect new changes you made on a table, you need to use the command

    update-database -verbose -force


    As long as you have an issue with this command in the package manager console, you may need to run this command, it will update entity to the latest version

    Update-Package EntityFramework
    

    Then restart your Visual Studio and try again

    if you need to update to specific version do the same but add -version

    Update-Package EntityFramework -version ""



    Thanks, Mahmoud

    Sunday, July 17, 2016 12:25 PM