Entity with Unmapped Property?

Discussion of open issues, suggestions and bugs regarding Entity Framework support in ADO.NET Data providers
Post Reply
cstahlsmith
Posts: 2
Joined: Mon 09 Dec 2013 21:01

Entity with Unmapped Property?

Post by cstahlsmith » Fri 03 Oct 2014 17:03

Is is possible to add an "unmapped" property to an entity (i.e. a property which has no data-storage column specified). If I try this by adding a new property and specify "none" for Storage Column, then the Entity Developer creates a compiler error "Problem in mapping fragments ... No mapping specified for ... An Entity with Key(PK) will not round-trip when: Entity is type [...]

I would like to add some extended properties to some entities for application use, that would be ignored for data-storage operations... but wanted to avoid wrapping each entity class in another class just for that purpose. I know, maybe it's bad design practice... but I was hoping this could be done with the EF designer and code generation.

Thanks

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Entity with Unmapped Property?

Post by Shalex » Mon 06 Oct 2014 16:00

cstahlsmith wrote:Is is possible to add an "unmapped" property to an entity (i.e. a property which has no data-storage column specified).
Yes, it is possible. You are working in Entity Developer, aren't you? Set the Generate Partial Class property of the template to True and create an unmapped property manually in the code.

If Generate Partial Class is set to True, then, for each class in the model, a partial class (%ModelName%.%ClassName%.cs) will be generated, in which the user can add code that is not overwritten be the designer. If %ModelName%.%ClassName%.cs was created before, it would be left unchanged (so you may need to remove it to regenerate the code with the new setting). The property can be used, if File Per Class is turned on.

Post Reply