Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Entity Framework v4: Preventing Storage Model Overwrites by Update Model Wizard

In my Entity Framework v4 project, I have a table with two columns that are computed by the database (via triggers, etc.). In order to get EF to properly insert records into the table, I have to manually mark the columns as "Computed" in the EF Storage Model (the StoreGeneratedPattern attribute), which is not supported by the designer -- so I have to make the edits by hand to the XML in the .EDMX file.

The problem is that whenever my database schema changes, and I need to update the storage model in my project, the "Update Model Wizard" overwrites the whole Storage Model section of the .EDMX, eliminating my manual changes. This means that I have to keep a special list of such changes and manually re-apply them EVERY TIME I do an update! For the love of god, this has got to be one of the dumbest glitches in EF.

Anyway, my question for the hive is this... Is there any way to prevent the Storage Model overwrites? Is there a way to flag the columns in the database, so that EF will automatically mark them as computed? As a last resort, is the some REALLY EASY XML tool/technique that can automatically apply the changes for me after every refresh?

THANK YOU, oh learned StackOverflow contributors for easing my pain and helping me with this problem even though I do not yet have any status on the site. Someday, when I have a 4+ digit reputation, I will remember you.

Brian


Update

I've been told by an insider that one solution might be to check out the "Designer Power Pack" (link below), which allows you to customize generation of the storage model. I've only skimmed the info so far, but it looks to me like there may be a day or two learning curve to figure that out. Does anyone have any experience with the Designer Power Pack, or any other ideas?

http://blogs.msdn.com/b/adonet/archive/2010/02/08/entity-designer-database-generation-power-pack.aspx

Thanks again, Brian

like image 933
BrianFinkel Avatar asked Jul 17 '10 20:07

BrianFinkel


1 Answers

According to the EF team at Microsoft, this is currently their biggest complaint from customers and also their highest-priority bug.

They say they have a solution designed and plan to ship it with the next release of Visual Studio, likely VS 2010 SP1, but no date on that.

Unfortunately, no good workaround has come up from any sources, but I'm still open to ideas!

Brian

like image 118
BrianFinkel Avatar answered Sep 24 '22 10:09

BrianFinkel