SharpDevelop Community

Get your problems solved!
Welcome to SharpDevelop Community Sign in | Join | Help
in Search

Using Entity Framework, what is the best way to update the model when the database schema changes?

Last post 06-19-2012 9:55 PM by devcrew. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 06-19-2012 7:40 PM

    Using Entity Framework, what is the best way to update the model when the database schema changes?

    Hi,

    I'm using #develop 4.2 build 8783 for a WPF project, with the Caliburn.Micro MVVM framework.  I added an Entity Framework to the project and it built a usable EF model of a SQL Server database.  Later, the database schema was updated and so the EF model needed to be udpated.  The EF update procedure with MS Visual Studio is via the Model Browser.  Understandably that's a feature of VS, and not #develop.  So, I decided to update the EF model by deleting the existing EF model from my project, and then create it again with the Entity Framework template.  However, on adding the replacement EF model, which I assigned with the same class name as the prior EF model, #develop crashed.  So, I closed the project, and deleted all files in the project file system directory that referred to the EF model.  On opening the project in #develop I went through the procedure of adding an Entity Framework, and this time the edmx file was saved without error.  However, this new EF model doesn't appear in the Class browser, and the generated edmx file doesn't have the designer.cs class file attached to it.  So, the new EF model is unusable.  Is there a recommended way of updating the Entity Framework when the DB schema changes?  Thanks

    Filed under:
  • 06-19-2012 8:31 PM In reply to

    Re: Using Entity Framework, what is the best way to update the model when the database schema changes?

    The only way to update the model is to create it currently. If the code behind file (designer.cs) is not generated, which it does not seem to be when the model is recreated currently, right click the file in the Projects window and select Execute custom tool. This should regenerate the code behind file with your context and entity classes.

  • 06-19-2012 9:55 PM In reply to

    Re: Using Entity Framework, what is the best way to update the model when the database schema changes?

    Using the Execute custom tool automatically generated the Designer class and the csdl, msl, and ssdl files.  Thank you.

Page 1 of 1 (3 items)
Powered by Community Server (Commercial Edition), by Telligent Systems
Don't contact us via this (fleischfalle@alphasierrapapa.com) email address.