Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 through 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')?

like image 290
James McLachlan Avatar asked Mar 11 '26 02:03

James McLachlan


1 Answers

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.

like image 143
Graham Conzett Avatar answered Mar 14 '26 23:03

Graham Conzett



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!