locked
Update Database via Installer/Update Project RRS feed

  • Question

  • Hey everybody,

    I have a question: Which is the best way, to update a database automatically. I have developed an "code first" application (Entity Framework 6). Usually I change the database and code structure via the edmx file.

    How can i ensure that the database is updated for the customer?

    Maybe an updater application would be useful, but how would you implement that?

    Regards

    Adrian Peters




    Friday, April 27, 2018 12:07 PM

Answers

  • Hi Adrian Peters,

    >>How can i ensure that the database is updated for the customer?

    If you use entity framework code first, I would suggest that you could use entity framework migration to update your database.

    When you develop a new application, your data model changes frequently, and each time the model changes, it gets out of sync with the database. You have configured the Entity Framework to automatically drop and re-create the database each time you change the data model. When you add, remove, or change entity classes or change your DbContext class, the next time you run the application it automatically deletes your existing database, creates a new one that matches the model, and seeds it with test data.

    For more information, please refer to:

    https://docs.microsoft.com/en-us/aspnet/mvc/overview/getting-started/getting-started-with-ef-using-mvc/migrations-and-deployment-with-the-entity-framework-in-an-asp-net-mvc-application

    Best regards,

    Zhanglong


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, April 30, 2018 2:13 AM

All replies

  • How can i ensure that the database is updated for the customer?

    It's by you knowing DBA 101 and knowing how to use Database Administration Tools, which have nothing to do with an ORM acting like a database administration tool nonsense. 

    Saturday, April 28, 2018 1:53 PM
  • Hi Adrian Peters,

    >>How can i ensure that the database is updated for the customer?

    If you use entity framework code first, I would suggest that you could use entity framework migration to update your database.

    When you develop a new application, your data model changes frequently, and each time the model changes, it gets out of sync with the database. You have configured the Entity Framework to automatically drop and re-create the database each time you change the data model. When you add, remove, or change entity classes or change your DbContext class, the next time you run the application it automatically deletes your existing database, creates a new one that matches the model, and seeds it with test data.

    For more information, please refer to:

    https://docs.microsoft.com/en-us/aspnet/mvc/overview/getting-started/getting-started-with-ef-using-mvc/migrations-and-deployment-with-the-entity-framework-in-an-asp-net-mvc-application

    Best regards,

    Zhanglong


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, April 30, 2018 2:13 AM