views:

37

answers:

1

Hello,

i have two tables in DB: Foo and Bar

Using Entity Framework i want to create base entity which will contain properties which both tables have.

For example Foo has columns Id,CreateDate,FooValue and Bar has Id,CreateDate,BarValue

  • So BaseEntity should have Id and CreateDate properties
  • Foo should inherit BaseEntity and have FooValue
  • Bar should inherit BaseEntity and have BarValue

How to map properties to their tables in DB?

A: 

I assume you want Table per Concrete Type (TPC) - here is a blog post with a walkthrough. One could also think about modifing the tables and using Table per Type (TPT) but I think this would be a bad decision for columns like CreationDate because you will get one table containing the creation dates from all tables.

Daniel Brückner
thanks a lot...
aron