title: Postgresql stored procedure on .net Core()
body: <p>I am trying to move our current SQL Server database to PostgreSQL with .net Core 2.2.</p>
  
  <p>I converted all tables (constraints, index), views and stored procedures to Postgre SQL. I have keep all Dbset configuration(except for Connection string) for data models on backend.</p>
  
  <p>I have a problem about running stored procedure (in Postgres) within EF Core. Stored procedure returns a view. Try to map this view to DbSet with <code>FromSql()</code> method from Ef Core. It was running with SQL Server before</p>
  
  <p>The stored procedure in Postgre SQL:   </p>
  
  <pre><code> CREATE OR REPLACE FUNCTION public.getbyusername_vw_sys_menu_lang()
   RETURNS SETOF "VW_SYS_MENU_LANG"
   LANGUAGE sql
  AS $$
  
      --return query
      SELECT M.* FROM "VW_SYS_MENU_LANG" M
      where M."USERNAME" = 'Admin' -- parameters will be added
      limit 10;
  
  $$;
  </code></pre>
  
  <p>I got error in .net Core : </p>
  
  <blockquote>
    <p>The required column 'ID' was not present in the results of a 'FromSql' operation.</p>
  </blockquote>
  
  <pre><code> var sql = "SELECT GETBYUSERNAME_VW_SYS_MENU_LANG()";
  //var sql = "SELECT * FROM VW_SYS_MENU_LANG" //it works with view
   var result1 = dbSet.FromSql(sql) //error : The required column 'ID' was not present in the results of a 'FromSql' operation.
  </code></pre>
  
  <p><strong>MyDbcontext : DbContext</strong><br>
     ....<br>
     ....</p>
  
  <pre><code> protected override void OnModelCreating(ModelBuilder modelBuilder)
          {
              base.OnModelCreating(modelBuilder);
              modelBuilder.Entity&lt;VW_SYS_MENU_LANG&gt;(e =&gt; { e.HasKey(t =&gt; new { t.ID, t.LANG }); });
  </code></pre>
  
  <p>In postgres, I can run stored procedure without any error and it return the result as expected and <strong>ID</strong> column does exist with capital characters. I have converted all tables and column names as <strong>Capital</strong> letters.</p>
  
  <p>I think something should be edited on DbContext class on EF Core or Postgres stored procedure.</p>
  
  <p>------------ <strong>UPDATE</strong>  -------------</p>
  
  <p>Confused a bit , I was using Dbeaver to create and test PostgreSQL tables , functions etc.</p>
  
  <p>When I run <strong>SELECT GETBYUSERNAME_VW_SYS_MENU_LANG()</strong> function on Dbeaver it returns table with all columns and data:</p>
  
  <p><a href="https://i.stack.imgur.com/urojC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/urojC.png" alt="Bbeaver"></a></p>
  
  <p>When I run same function on <strong>Pgadmin</strong> , result is : </p>
  
  <p><a href="https://i.stack.imgur.com/KNarJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KNarJ.png" alt="enter image description here"></a></p>