entity framework - C# - EF 6 Multiple Tables To One FK -


I am preparing the database using Code First / Flat API and have encountered this question:

How to

This is a scenario:

I have an account chart with a 5-level hierarchy.

From top to Botton (one-to-many: excel 1 can be several axis 2 and so on, and AC 2 should be EX1):

Account 1 - > Account 2 -> Account 3 -> Account 4 -> Account 5

Example: A supplier can be in any account chart: 1 or 2 or 3 or 4 or 5. (This is a commercial automation Rule is).

How to work it using fluent APIs?

DB Model

Not only are you trying to do with EF; It is not possible in the database A single foreign key can only refer to a table

If the data requirements for account 1-5 are the same, you will need them to enter a foreign key Consideration should be considered which references the context:

  account - ----- accountindustate tap peak level (1-5) Parent ID intern FK (Reference Account (Account ID)) Other Column Assunded Supplier ------ supplier Id not F tap (Reference accounts (Akountaidi)) Perentaid Int zero FK (reference account (Account ID))  

It would be very easy to do modeling in EF. You will need to retain some business rules in the code (such as Level 2 should be level -1 ParentId in the account).


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -