EF4 (CPT5) ForeignKeyAttribute in base class - Assert Failure entityType != null

Posted by Anthony Johnston on Stack Overflow See other posts from Stack Overflow or by Anthony Johnston
Published on 2011-01-16T15:34:09Z Indexed on 2011/01/16 16:53 UTC
Read the original article Hit count: 142

Filed under:
|
|

Getting an error when trying to set a ForeignKeyAttribute in a base class

class User{}

abstract class FruitBase{

   [ForeignKey("CreateById")]
   public User CreateBy{ get; set; }

   public int CreateById{ get; set; }

}

class Banana{}

class DataContext : DbContext{

   DbSet<Banana> Bananas{ get; set; }
}

If I move the FruitBase code into the banana, all is well, but I don't want to, as there will be many many fruit and I want to remain relatively DRY if I can

Is this a know issue that will be fixed by March? Does anyone know a work around?

© Stack Overflow or respective owner

Related posts about c#

Related posts about entity-framework-4