ASP.net Core 7 MVC same model multiple times

tjestesjr77 20 Reputation points
2023-04-25T14:16:13.6933333+00:00

I have a data model where I am connecting to the same table 3 times. I can do this in SQL by using aliases, but I am unsure if it is possible to do this in ASP.NET Core 7 MVC. Are you able to "alias" a model in ASP.NET MVC? TechFeeERD

Developer technologies | .NET | Entity Framework Core
Developer technologies | ASP.NET | ASP.NET Core
{count} votes

1 answer

Sort by: Most helpful
  1. AgaveJoe 30,406 Reputation points
    2023-04-25T19:06:38.22+00:00

    It is an Entity Framework question. Within EF how is it possible to have the same model 3 times in one view?

    Yes. See the EF Core relationship documentation. Self-referencing one-to-many Keep in mind, you can still write any SQL you like even if you are using Entity Framework. SQL Queries

    EF Core Raw SQL Query

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.