title: Right way to use ORM in ASP.NET Core MVC?
body: <p>An inexperienced web developer crying out for help!</p>
  
  <p><strong>Introduction</strong></p>
  
  <p>I am developing an MVC web app (using ASP.NET Core due to my interest in it).
  In the back-end, there is an MSSQL Server with quite sophisticated Databases (thousands of tables).
  In my project, I'd like to present part of the public data in the View (in Tables), based on the user's queries (sending Form requests) and later allowing the user to download the data (CSV, XML).</p>
  
  <p><strong>Architecture challenges</strong></p>
  
  <ul>
  <li><em>Data Access Layer</em></li>
  </ul>
  
  <p>First I started with using Entity Framework but later realized that simply can't translate all my SQL statements to LINQ. The reason is the simplest query contains several INNER JOINS and LEFT JOINS and SELECT statements and an endless number of Tables.</p>
  
  <ul>
  <li><em>Business Logic Layer</em></li>
  </ul>
  
  <p>I am planning to build a REST API, sending the data in JSON format. As far as I concerned in .NET Core MVC I can have my API Controller in the same project as my presentation layer.</p>
  
  <ul>
  <li><em>Presentation Layer</em></li>
  </ul>
  
  <p>This is the only part I have experience with, building web apps using MVC 5.</p>
  
  <p><strong>The big struggle</strong></p>
  
  <p>In this project, I will not manipulate the data, only READ it and present them to the user. I am aware the guidelines of using different Model class (Domain, Entity, ViewModel)</p>
  
  <p><strong><em>What I do now, and I suppose it's wrong:</em></strong></p>
  
  <ul>
  <li><p>The MVC's API Controller returns the SQL query results as type DataTable object (have an SQL Helper class to do the job), so far my controller takes care of serializing the objects as JSON.</p></li>
  <li><p>Another Controller (with model binding from the view) gets the user search criteria via HTML-forms and calls the API Controller with binding the corresponding properties.</p></li>
  </ul>
  
  <p><strong><em>The questions finally</em></strong></p>
  
  <ul>
  <li>Am I supposed to stick to raw SQL queries instead of Entity Framework, and if so, shall I use simply separated class libraries (as Data Access Layer) and reference it in the API? Or leave out the DAL and put all the SQL query logic into the API?</li>
  <li>Does one need to use Entity Framework in case of only reading the
  Data without manipulating it? The only manipulation I intend to do is to format the look-and-feel in the logic layer.</li>
  </ul>
  
  <p><strong><em>UPDATE EDIT:</em></strong></p>
  
  <p><strong>In my SQL queries, I must create temporary tables which are not supported in LINQ. Any suggestions?</strong></p>
  
  <p>In case this question will be marked as an architectural and not a programming one, please accept my apologies and kindly refer me to the right forum where I could get help.</p>
  
  <p>Many thanks in advance!</p>