How to call a Stored Procedure in Code First Entity Framework

	using (var _dbContext = new TestDbContext())
		//Open Database connection
		//Create command object
		DbCommand _cmd = _dbContext.Database.Connection.CreateCommand();
		//Set procedure name as command text
		_cmd.CommandText = "SPName";
		//Set command type to stored procedure
		_cmd.CommandType = CommandType.StoredProcedure;
                // Set input parameter value
		_cmd.Parameters.Add(new SqlParameter("@Id", 100));

                //Set Out put parameter value
		var _resultParam = new SqlParameter("@Result", SqlDbType.NVarChar, 1000)
                { Direction = ParameterDirection.Output };

	    return _strResult = _resultParam.Value != null ? _resultParam.Value.ToString() 
                                : "Error Message!!!";

Programming is Easy…