1

Say I have the following classes:

class Tag
{
    public int Id {get; set;}
    public string Name {get; set;}
}

class EntityA
{
    //ctor, other properties, etc
    public List<Tag> Tags {get; set;}
}

class EntityB
{
    //ctor, other properties, etc
    public List<Tag> Tags {get; set;}
}

Is there a way in EF to map my lone Tag class to 2 unrelated tables (EntityATag and EntityBTag) as well as their linking tables (EntityA_EntityATag)? For query performance reasons I want to have 2 separate Tag tables, but am hoping I can keep working with just one Tag class instead of a class per table.

Thanks!

UPDATE: This is NOT the same question as mapping multiple tables to a single entity class in entity framework. That question is about splitting a single class into multiple tables. I don't want to split my Tag class, I want to map the full class to two different tables depending on which entity I'm working with (EntityA or EntityB)

Community
  • 1
  • 1
IWriteApps
  • 973
  • 1
  • 13
  • 30

1 Answers1

0

This is more about the EF implementation. Having had a similar problem some time ago I found that this reference hit the spot.

You could implement tag as an abstract class.

Peter Smith
  • 5,528
  • 8
  • 51
  • 77