Model model=new Model();
model.id=0;
model.name="";
model.surname="";
db.Model.Add(model);
db.SaveChanges();
int id_returned=model.id;
This block gives me the id field of the inserted row.
But i use stored procedure for this insert process.
Model model=new Model();
model.id=0;
model.name="";
model.surname="";
int returned_id2=db.Sp_Model_insert(model.name, model.surname);
this block inserts the row. returned_id2 returns -1.
How can i get the row id that inserted via Sp ?
Here is my Stored Procedure:
USE [KayaShop]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [KS_ACCOUNTS].[SP_AccountModules_Insert](
@Area nvarchar(50),
@Controller nvarchar(50),
@Action nvarchar(50),
@SubAction nvarchar(50),
@Name nvarchar(50),
@TopName nvarchar(50),
@Level int,
@Visible int,
@Clickable int,
@HomePage int,
@Icon nvarchar(20),
@Status int
)
AS
BEGIN
SET NOCOUNT ON
INSERT INTO [KS_ACCOUNTS].[AccountModules]
([Area]
,[Controller]
,[Action]
,[SubAction]
,[Name]
,[TopName]
,[Level]
,[Visible]
,[Clickable]
,[HomePage]
,[Icon]
,[Status])
VALUES
(@Area,
@Controller,
@Action,
@SubAction,
@Name,
@TopName,
@Level,
@Visible,
@Clickable,
@HomePage,
@Icon,
@Status)
END