The first exception of type "System.Data.Entity.Core.EntityCommandExecutionException" exception occurred in EntityFramework.SqlServer.dll

I am trying to call a stored procedure using the framework 6 entity. I get an error message on the output message.

The first random error like "System.Data.Entity.Core.EntityCommandExecutionException" occurred in EntityFramework.SqlServer.dll

 using (var context = new PartnerPortalEntities2())
 {
    var outputParameter = new ObjectParameter("result", typeof(string));
    var spresults = context.assignRoles_CreateAccountAndContacts(user.Id, role, user.AccountId, user.AccountName, user.ContactId, user.FirstName, user.LastName, outputParameter);
    // Control never comes after the above line
    if(spresults.Equals("1"))
    {
       //Do something
    }
    else
    {
        // Do something
    }

    }

When I do debugging, the control goes to the line where the stored procedure is called, after which we get the above error in the output window and the debugger stops, it never gets into the if statements.

I ran the stored procedure on SQLserver and it works great. Any thoughts that might be a mistake. I created the context by creating code from the database.

+4
2

@Shoe, try try, .

, . , , ,

var outputParameter = new ObjectParameter("result", typeof(string));
+1

, !

, , SQL- - IP- Sql .

, .

0

All Articles