This is something that I would expect to be simple but it is not working. I simply want to be able to create stored procedures in my SQL Server DB and call them from within my MVC3 web app. I have managed to get my SPs imported into a generated function but when I call this I get an error:
The data reader is incompatible with the specified 'dbname.school_accreditation'. A member of the type, 'school_accreditation_id', does not have a corresponding column in the data reader with the same name.
I have created a stored procedure within SQL Server.
USE [mydb]
GO
/****** Object: StoredProcedure [dbo].[DeleteSchoolAccreditations] Script Date: 02/07/2014 20:56:21 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[DeleteSchoolAccreditations]
@school_id int
AS
DELETE FROM [dbo].[school_accreditation]
WHERE school_id = @school_id
The generated c# function to call the SP.
public virtual ObjectResult<school_accreditation> DeleteSchoolAccreditations(Nullable<int> school_id)
{
((IObjectContextAdapter)this).ObjectContext.MetadataWorkspace.LoadFromAssembly(typeof(school_accreditation).Assembly);
var school_idParameter = school_id.HasValue ?
new ObjectParameter("school_id", school_id) :
new ObjectParameter("school_id", typeof(int));
return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<school_accreditation>("DeleteSchoolAccreditations", school_idParameter);
}
Should I need to do anything to this generated method in order to get it to work. I am passing in an int to the method and it all looks okay when I debug.
Please any help would be greatly received.
Joe