title: How can i get id of inserted record Using Entity Framework
body: <p>I have a problem with Entity Framework in Asp.net. I want to get the Id value whenever I add a record to the SQL database table. How can I do this?
  Here is my code:</p>
  
  <pre><code>StoredProcedure 
  
  
  
  USE [Sapphiresworld]
  GO
  /****** Object:  StoredProcedure [dbo].[addProduct]    Script Date: 7/4/2018 10:25:41 AM ******/
  SET ANSI_NULLS ON
  GO
  SET QUOTED_IDENTIFIER ON
  GO
  ALTER Proc [dbo].[addProduct]
  @title nvarchar(250),
  @price nvarchar(50),
  @unitID int,
  @date nvarchar(50),
  @subCategoryID  int,
  @brandID int,
  @vat int,
  @discount int,
  @picture nvarchar(50),
  @stock int
  as
  declare @MyVal int=0
  INSERT into [PRODUCT] values (@title,
  @price ,
  @unitID,
  @date,
  @subCategoryID  ,
  @brandID ,
  @vat ,
  @discount ,
  @picture ,
  @stock)
  Set @MyVal = @@IDENTITY
  Select @MyVal as Val
  </code></pre>
  
  <p>Here is ClsBrand</p>
  
  <pre><code>        public string AddBrand(string brandName)
     {
     var result = new SapphiresworldEntities().AddBrand(brandName).ToString();
  
          return result;       
     }
  </code></pre>
  
  <p>Code against Save Button</p>
  
  <pre><code>  protected void Btnsave_Click(object sender, EventArgs e)
  {
              clsBrand nb = new clsBrand();
        string nwBran = nb.AddBrand(relig.Text);
  
  }
  </code></pre>