How can i get the row id that inserted via stored procedure?
<pre><code>Model model=new Model();
model.id=0;
model.name="";
model.surname="";
db.Model.Add(model);
db.SaveChanges();
int id_returned=model.id;
</code></pre>

<p>This block gives me the id field of the inserted row.</p>

<p>But i use stored procedure for this insert process.</p>

<pre><code>Model model=new Model();
model.id=0;
model.name="";
model.surname="";
int returned_id2=db.Sp_Model_insert(model.name, model.surname);
</code></pre>

<p>this block inserts the row. <strong>returned_id2</strong> returns <strong>-1</strong>.</p>

<p>How can i get the row id that inserted via Sp ?</p>

<p>Here is my Stored Procedure:</p>

<pre><code>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
</code></pre>