Answer the question
In order to leave comments, you need to log in
How correctly in EF core (code first) to organize work with columns of a composite type table?
I am studying EF core and working with Postgres, I ran into the problem of organizing the accounting of goods in the warehouse.
For example:
there are more than 2 tables for storing documents that are completely different in structure, an incoming invoice, an outgoing invoice, write-offs, transfers, etc. ...
and there is one table with records reflecting some changes, for example, the movement of goods in a warehouse.
It is necessary that in one of the columns the value of the one to whom this entry refers, i.e. link to the invoice...
I tried with inheritance, but TPT is not supported in ef core, and the TPH option does not suit, because it turns out a very cumbersome table.
Answer the question
In order to leave comments, you need to log in
I would look in the direction of making the unique part in json, and leave what is repeated in ordinary SQL columns. On the server side, you can add a field to the entity that will parse the object from the json string. It is necessary to add ignoring this field to the configuration.
Or the 2nd option. Table on the type and then make a view that combines them by common columns. General data can be obtained for everyone from one view, details are obtained from a specific table.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question