You can set the theme_location
of the menu programmatically with:
$locations = get_theme_mod('nav_menu_locations');
$locations['primary-menu'] = $term_id_of_menu;
set_theme_mod( 'nav_menu_locations', $locations );
Add this to your functions.php
.