none
Entity framework model first, make changes to the database without dropping tables? RRS feed

  • Question

  • I was doing a database first design, and updating my edmx as i made changes on the database. Now, instead, I switched to to making changes to my edmx model, and use the generate database from model to generate all the SQL to create the database.

    However.. I don't want to lose the data in the tables each time I make a change. Instead of dropping and rebuilding the tables, is there a way I can just update the database objects without dropping everything first..?

    Thanks.

    Wednesday, March 27, 2013 8:57 PM

Answers

  • Hi  Xyc0se,

    Welcome to the MSDN forum.

    EF's default database generation workflow creates a full script that will recreate your database every time you select Generate Database from Model, so if you execute it in your DB you will lose all your data. However, if you just create a new Entity and did not change the existing ones, then you can still generate database from your Model but then take that script and only run the part that creates the new table for your new entity.

    Another way would be to install Entity Designer Database Generation Power Pack from Microsoft which only support Entity Framework 4.

    Have a nice day.


    Alexander Sun [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, March 28, 2013 8:48 AM