Question

I'm starting a new project using EF 4.1, database first. If I generate the edmx using Visual Studio, then everything is fine; however I can't seem to figure out a way to refresh the edmx when there are changes to the database short of deleting & re-adding it.

In a previous project (using EF 3.x?), we had scripts to do this - edmgen to create the csdl, msl, and ssdl, and then edmgen2 to create the edmx and designer.cs files.

Do I still need to use edmgen2 to create edmx files? Or is there a way with the VS2010 version of edmgen to do this?

No correct solution

OTHER TIPS

I created a feature request here:
http://data.uservoice.com/forums/72025-entity-framework-feature-suggestions/suggestions/3022790-edmgen-exe-should-support-generating-an-edmx-file-

There are also similar discussions here:
http://social.msdn.microsoft.com/Forums/sa/adodotnetentityframework/thread/a98cddf4-5975-4c20-b88d-d308ed7fa45f

http://social.msdn.microsoft.com/Forums/en/adonetefx/thread/d93cde02-7534-489c-a1bd-72f45ce404be

There is a blog post here:
http://weblogs.asp.net/manavi/archive/2011/05/17/associations-in-ef-4-1-code-first-part-6-many-valued-associations.aspx
(Hint: search for "Get the Runtime EDM")

Those last two links provide the answer:

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
  // Additional configuration

  var provider = new DbProviderInfo("System.Data.SqlClient", "2008");
  var model = modelBuilder.Build(provider);
  model.WriteEdmx(provider, new XmlTextWriter(@"C:\temp\my.edmx", Encoding.ASCII));
}

Right mouse click in the edmx designer and choose update model from database you will get a popup where you can choose what objects needs updating

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top