开发者

Denormalizing with Entity Framework

I recently heard someone suggest that Entity Framework could be used to denormalize data. For instance, let's say you have a table of game genres and a table of games.

Your initial EF model might get to the name of a game's genre through game.Genre.Name. Apparently there is a way to remap things so that you can get to the game's genre name throu开发者_JAVA百科gh game.GenreName.

I can't find an example of this, though. The only approach I know of is to manually add a layer of abstraction that maps this (e.g. new GameAbstraction() {GenreName = gameEntity.Genre.Name }).

Is this something EF can do, or is it all about increasing normalization (e.g. creating SportsGame when Genre.Name == 'Sports' or ActionGame when Genre.Name = 'Action')?


I've done this with a pretty reasonable degree of success, mapping denormalized tables into a normalized entity framework, and vice versa. I started out by using the designer provided with entity framework, you can actually drag and drop properties around the diagram to build new entities...

However, I'm of the opinion that the UI + tools for doing this isn't quite there yet in terms of automation or ease of use. Some stuff just doesn't map the way you expect or want it. If you plan on doing a lot of denormalization you will end up doing a lot of hand editing of the XML behind the designer. This is what I've had to do for a while now on my most recent project.


Yes, it's called entity splitting. Here's a tutorial.

I agree with @Graham that you shouldn't try it if you're uncomfortable with XML editing, though.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜