locked
Adding New Field With Code First Approach on Production Environment RRS feed

  • Question

  • User-1104215994 posted

    Hi guys,

    I would like to add a new field to an existing table. I can do add migration and update database commands on the development environment. I wonder how can I update the production database?

    Best Regards.

    Wednesday, April 22, 2020 12:29 PM

Answers

  • User475983607 posted

    I would like to add a new field to an existing table. I can do add migration and update database commands on the development environment. I wonder how can I update the production database?

    It works the same way.  Or you can get the TSQL script from the migration and and execute the script.  Or you can write code in your app startup that invokes migrations that have not been invoked yet. 

    Keep in mind, this information is openly available in the official documentation.  

    https://docs.microsoft.com/en-us/ef/core/managing-schemas/migrations/?tabs=dotnet-core-cli

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, April 22, 2020 12:54 PM

All replies

  • User475983607 posted

    I would like to add a new field to an existing table. I can do add migration and update database commands on the development environment. I wonder how can I update the production database?

    It works the same way.  Or you can get the TSQL script from the migration and and execute the script.  Or you can write code in your app startup that invokes migrations that have not been invoked yet. 

    Keep in mind, this information is openly available in the official documentation.  

    https://docs.microsoft.com/en-us/ef/core/managing-schemas/migrations/?tabs=dotnet-core-cli

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, April 22, 2020 12:54 PM
  • User-1104215994 posted

    Thank you, running this script should work.

    ALTER TABLE tablename ADD columnname [nvarchar](30)

    Wednesday, April 22, 2020 3:53 PM