1

I am using EF6 and I am trying to get the table sizes. I believe this should work but the result comes back as zero:

public class SqlRes{
    public int Size { get; set; }
}

var size = DbContext.Database.SqlQuery<SqlRes>("exec sp_spaceused Customer").ToList();

I have also tried to use type like string or int with no success. Please help.

BPDESILVA
  • 2,040
  • 5
  • 15
  • 35
Stackedup
  • 680
  • 2
  • 9
  • 26
  • Possible duplicate of [How to call Stored Procedure in Entity Framework 6 (Code-First)?](https://stackoverflow.com/questions/20901419/how-to-call-stored-procedure-in-entity-framework-6-code-first) – gsharp Jul 17 '19 at 03:20

1 Answers1

1

The property names of SqlRes should match the column names returned by the stored procedure.

According to SQL Docs, the column names are:

  • name
  • rows
  • reserved
  • data
  • index_size
  • unused

Try changing your SqlRes class to have those property names.

Rowan Freeman
  • 15,724
  • 11
  • 69
  • 100