The text book way of working is to develop your controller inside a separate Simulink model file, and then using a simulation harness model which has a model reference to that controller file, and then another embedded coder harness model which has a model reference to the same controller file. This way, you develop the same controller in simulation or embedded coder environment, but the controller content remains the same.
Alternatively, you can use Variant Subsystems where you switch between simulation and code generation using a variant object. You can manually switch the variant object, but you can also use a condition expression like:
This condition will be true when you are using the Configuration Parameters for code generation, and false in any other situation like simulation. Your controller is stored in file model_name.slx in this example.