I use the DataBase First approach. There are three tables in the database where hospital admission information is stored: Visit (patient admission information, including admission id), Analysis (id and name of a specific type of analysis) and Visit_Analysis (admission id is compared and analysis id to determine what tests were assigned at what receptions).

When creating a model from a database, it produces two tables, Visit and Analysis, and the Visit_Analysis table is made in the form of an association with the name Visit_Analysis.

The question is, is it possible from the program code to perform a query in the database using EntityFramework to add records or read from the Visit_Analysis table? because There is no Visit_Analysis entity in the DbContext class.

  • In Entity, you should have something like this class Vist { ... List<Analysis> analysises ... } and / or class Analysis { ... Visit visit ... } And this is enough. Visit_Analysis is processed by the framework instead of you. - Sergey
  • All so, in the class of Visit has a field ICollection <Analysis>. And how do I fill this collection? - Andrei
  • I query the Analysis table to get a variety of Analysis objects whose names have been selected by the user in the form and get IQuaryable <Analysis>. It’s impossible to bring IQuaryable <Analysis> to ICollection <Analysis>, and when I try to access IQuaryable <Analysis> element by element, I’ll fail to add each element to ICollection <Analysis>, since an error occurs: The LINQ expression type "ArrayIndex" of the LINQ expression is not supported in LINQ to Entities. - Andrei
  • How do you select Analysis from the IQuaryable <Analysis> element by element, which results in an ArrayIndex element instead of an Analysis type element? - Sergey
  • using foreach - Andrei

0