Use Output Parameter with Entity Framework (Edmx) in C# .Net

Last Reply on Aug 09, 2015 04:32 AM By dharmendr

Posted on Aug 07, 2015 09:26 AM

I have develop a function to add textbox value into data base my function work perfectly .now I am using that table primary key into another table where it declare as a foreign key now i required to return my Id as a output parameter in table1  means( set scope identity)    so that I used this Id into another table as a foreign key please help me how I used this scope identity into a web method

function Insertdata()
               var name  = $('#txtfname').val();
                         type: 'POST',
                         url: "Insert.aspx/DataInsertion",
                         contentType: "application/json; charset=utf-8",
                      data: '{name:"' + name + '", Id:"' + output + '"}',

                         async: false,
                         success: function (response) {
                             alert(" Saving the Data.!");

                       error: function () {

                             alert("Some Error occured While Saving the Data.!");



Web method 
    public static string DataInsertion(string name Id output)
        using (var db = new MyEntities())///////this is edmx name



            return " Data Successfully Saved";


I read a lot of article but I have no idea to use it.

Please help me