Reusing a complex type

Creating a new complex type couldn’t be simpler, but I usually want to reuse that type in multiple places in my model, and that’s a little more complicated. Not a lot (particularly now that you know how to use the Mapping Details window), but a little.

The Entity Model Designer doesn’t have intrinsic support for reusing complex types. There’s no “Refactor into existing Complex Type” option, so the easiest way I’ve found to do it is to first refactor to a new type,  and then change the type and mapping properties:

Image

Create a new complex type from the properties you want to map to the existing type (the properties representing ...

Get Fluent Entity Framework now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.