I am creating an application using C#/.net 4.5 and EF 6 and was wondering if I could do the following somehow:

I have two base classes like:

```
public class BaseItem
{
    [Key]
    public int Id { get; set; }

    public List<BaseRevision> Revisions { get; set; }
}

public class BaseRevision
{
    [Key]
    public int Id { get; set; }

    public BaseItem Item { get; set; }
}

```

Now I derive both of them like the following:

```
[Table("ContentItems")]
public class ContentItem : BaseItem
{
    public string ContentType { get; set; }
}

[Table("ContentRevisions")]
public class ContentRevision : BaseRevision
{
    public string Text { get; set; }
}

```

This works fine and EF even handles queries like:

```
var revisions = db.ContentItems.Where(i => i.Revisions.Any(r => (r as ContentRevision).Text.Contians("ABC")));

```

This is converted to SQL as I would expect, but I would like to "get rid if the `as`" (it causes much more complication in some other cases).

I tried using generics for `BaseItem`, but that is not supported by EF so I tried the following:

```
[Table("ContentItems")]
public class ContentItem : BaseItem
{
    public string ContentType { get; set; }

    public List<ContentRevision> ContentRevisions { get; set; }
}

[Table("ContentRevisions")]
public class ContentRevision : BaseRevision
{
    public string Text { get; set; }

    public ContentItem ContentItem { get; set; }
}

```

So I could use the above query like:

```
var revisions = db.ContentItems.Where(i => i.ContentRevisions.Any(r => r.Text.Contians("ABC")));

```

But I can't get it working using the inherited foreign key "Item\_Id" in the "BaseItems" table. EF allways wants to create a second FK-Relation using a new "ContentItem\_Id" key in the "ContentItems" table, which would duplicate the relation (and maybe cause some other side-effects).

**Is this somehow possible (or has someone a better idea to solve/improve this problem/pattern)?**

UPDATE: Demo project can be downloaded [HERE](https://www.dropbox.com/s/n6z18lrk4dt68jr/EfGenericTest.zip). If you add a new migration it will create the second FK-mapping I do not want...