How to create ADO.NET Entity Data Model from SQL query with JOIN?

  • Hi,
    I have created .NET Console Application (C#). My SQL Server database has 3 tables. I created ADO.NET Entity Data Models for those tables in my project by Entity Framework Database First guide. They work fine, but I need to create another model for my SQL Query which is following:

    SELECT users.name, users.userid, COUNT(userlogs.userid)
    FROM users
    LEFT JOIN userlogs ON users.userid = userlogs.userid
    GROUP BY users.name, users.userid

    It is expected to get users names, userids and counts of logs in userlogs table. Then my mission is to loop through these and create string which I use to show "Top 5 most causes for logs".
    How should I go about creating required DbSet and Model like the generated ones from tables?

    I'm using Visual Studio 2017, SQL Server 2012, Entity Framework 6.4, .NET 4.6.x.

    Thank you

Viewing post 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply