Entity Framework 5.0 inheritance with multiple assemblies -
i'm using entity framework 5.0 code-first approach plus inheritance business objects represented table per hierarchy.
i'd have following structure:
//assembly 'dataaccess' public class mydbcontext : dbcontext { dbset<abstractclass> commonobjects.abstractclasses { get; set; } } //assembly 'commonobjects' public abstract class abstractclass { //implementation } //assembly 'derivedobjects' public class derivedclass : abstractclass { //implementation } during runtime, when trying access dbcontext first time, compiler throws invalidoperationexception saying:
the abstract type 'commonobjects.abstractclass' has no mapped descendents , cannot mapped. either remove 'commonobjects.abstractclass' model or add 1 or more types deriving 'commonobjects.abstractclass' model.
is scenario possible? if yes, doing wrong?
thanks answers in advance.
ben
additional information:
maybe should bit more specific:
i got 1 assembly containing abstract business objects (only abstractions). concrete implementations (containing logic) kept in responsible assemblies, logic depends upon other classes within assembly. issue is, want able store conrete implementations in persistance layer well. purpose, ef had know types in order enable mapping. dont want make persistance layer depend on business logic layer - abstractions.
that's why tried add derived objects dbcontext directly business object layer.
example:
abstractclass derivedclass = new derivedclass(); mydbcontext.abstractclasses.add(derivedclass); but exception above being thrown. can't figure out structure achieve this.
Comments
Post a Comment