Categories
c# entity-framework sql sql-server stored-procedures

Database.ExecuteSqlCommand always returns -1

I have a EF code-first model. It is working fine, but when I try to run a stored procedure with Database.ExecuteSqlCommand it always returns -1, it doesn’t matter what I put in the stored procedure result is always -1

My stored procedure:

CREATE PROCEDURE [dbo].[Login_user] 
@clientKey varchar(max)
AS
BEGIN
SET NOCOUNT ON
RETURN(0)
END

And I run it like:

return Database.ExecuteSqlCommand(EXEC [dbo].[Login_user] {0}", key);

Am I missing something?

By the way if I run the stored procedure from SQL Server Management Studio it returns 0

USE [lo9iMed]
GO
DECLARE @return_value int
EXEC @return_value = [dbo].[Login_user]
@clientKey = N'76F41F99-EA9E-4181-A6FB-579D23D3C2C0'
SELECT 'Return Value' = @return_value

Thanks in advance.

anibal