none
Alternative to update database instead of “Generate Database from Model” (Visual Studio 2010) RRS feed

  • Question

  • Hey everybody,

    I have created a Entity Framework 4 model with Visual Studio 2010 and generated a database from it. Now I found myself adding new properties (with default values), changing documentation of columns, changing names of columns, changing types of columns several times. All tasks that do not require much "extra work" in order not to be possible to be achieved automatically (in my humble opinion). Everytime I did "Generate Database from Model" and lost of course the table data.

    Is there a way just to update the database's architecture so to say - leaving the table data untouched? Maybe with some user interaction especially when changing types etc.? Or would this functionality be simply too difficult to be realized to work in a reliable way?

    Or is there any other nice way/work-around to achieve what I need? Using two DB etc. for example?

    Thanks in advance! Sincerely, Tlgtlg

    Thursday, June 17, 2010 7:55 AM

Answers

All replies

  • We've build the entity designer database power pack to support this. You can download it here: http://visualstudiogallery.msdn.microsoft.com/en-us/df3541c3-d833-4b65-b942-989e7ec74c87

    It includes a database generation workflow for the designer that does migration, rather than drop/create.


    This posting is provided "AS IS" with no warranties, and confers no rights.
    Tuesday, June 22, 2010 4:32 PM
    Moderator
  • Hi,

    How does it work? It is possible to install it on vs 2010 express?

    I tried to install it, but still I can't find the way to update my db instead to recreate it.

     

    Thanks for you time!

    Friday, October 8, 2010 6:46 PM
  • The database generation power pack works by giving you a number of Workflow Foundation XAML workflows that replace the one shipped with the designer. Now, Visual Studio express does not allow certain kinds of core extensibility, but you should still be able to replace the workflow specified in the designer with one of the ones shipped with the power pack - if you click on an empty area of the designer canvas and look at the properties grid, you'll see a property that specified a database generation workflow. You can edit that property and point it at one of the power pack's workflows.

    There is a good deal of documentation on MSDN on how to customize the database generation pipeline that was shipped in the designer.


    This posting is provided "AS IS" with no warranties, and confers no rights.
    Monday, October 11, 2010 5:55 PM
    Moderator
  • Yet another alternative is my 'Model Comparer' for EFv4. It is part of an add-in that plugs right into Visual Studio, and gives you an overview and more precise control over differences and allows you to generate SQL-DDL for individual diffs. It also allows you to make selective updates the other way. I have posted a brief intro video at http://huagati.blogspot.com/2010/07/introducing-model-comparer-for-entity.html and if you want to try it out you can download it and get a trial license from http://huagati.com/dbmltools/

     


     
       Cool tools for Linq-to-SQL and Entity Framework 4:
     huagati.com/dbmltools - Rule based class and property naming, Compare and Sync model <=> DB, Sync SSDL <=> CSDL (EF4)
     huagati.com/L2SProfiler - Query profiler for Linq-to-SQL and Entity Framework v4
    Wednesday, October 13, 2010 11:00 AM