Could we have Interfaces in CodeFirst in NakedObject ?

Jun 12, 2012 at 9:19 AM

It seems CodeFirst does not allow to have Interfaces.

Tried to use NotMapped attribute, Ignore attribute etc. But still does not solve the problem. 

Any Solution ?



Jun 12, 2012 at 9:29 AM

If you mean: having a property that is defined by an interface rather than a class, then this is a limitation of Entity Framework, not Naked Objects.  However, we do provide a good workaround.  This is shown in the developer manual.  Search for 'How to handle associations that are defined by an interface rather than a class'.

Jun 12, 2012 at 9:48 AM

Thanks Richard,

We understand the approach for a property that is declared as an interface type.  When we run a 'code first' project the entity framework complains that an interface

(with a number of properties included in it) is not mapped.

We tried using the [NotPersisted] attribute for each of the interface properties but the EntityFramework still complains that the Interface is not mapped. We also tried using the NotPersisted attribute at the interface level but this attribute is not supported by the EntityFramework.


Would you know how tell the EntityFramework to ignore the interface from a mapping perspective?


Jun 12, 2012 at 10:03 AM

Ah, OK.  You will need to do that using configuration.  If you look up 'How to specify configuration details with Code First' in the manual, this will show you where you can specify configuration  -  but not how specifically to configure that requirement.  You'll need to look that up on the online sources of help for EF Code First  -  it is not specific to Naked Objects.