0

I'm using EF Core 1.0 (although I guess it's generic question for EF).

I have table Resource, Employee and Equipment (Resource is like a base table, meaning Employee is also Resource and Equipment is also Resource).

So when creating Employee record I would like to automatically insert record into Resource table.

All tables has ID column.

Resource.ID is PK identity.

Employee.ID is PK (not identity) - it's FK to Resource.ID

Is there sexy way of doing it in EF (other than manually adding both records in my code)?

Thanks!

currarpickt
  • 2,290
  • 4
  • 24
  • 39
pankleks
  • 693
  • 6
  • 14
  • Is there inheritance between the entities on code level? If so, then you can apply some inheritance managed by EF as it is described [here]|(http://www.entityframeworktutorial.net/code-first/inheritance-strategy-in-code-first.aspx). – AndrasCsanyi Jul 20 '16 at 11:07
  • No - there separate classes in my code. Also I'm using EF core, which supports ATM TPH only. – pankleks Jul 20 '16 at 11:23
  • TPH is not good for you in this case? However, I have found this when I searched for trigger and EF: http://stackoverflow.com/questions/21943314/entity-framework-6-code-first-trigger – AndrasCsanyi Jul 20 '16 at 11:34
  • I think I need to wait for TPC features in EF Core. Thanks anyway! – pankleks Jul 24 '16 at 10:11

0 Answers0