A computer-implemented method modifying templates in a code generation process comprising: receiving a template for generating code; receiving a model for generating code; processing the template and the model in a code generator, and in accordance therewith, generating code based on the model and the template; receiving a modification to the generated code, and in accordance therewith, producing modified code; and automatically changing the template based on the modified code to produce a modified template, wherein processing the modified template and the model in the code generator automatically generates said modified code, the method further comprising mapping one or more elements in said template to corresponding elements in said generated code, wherein the element in said template preferably caused the element in said generated code to be generated, wherein the template comprises a plurality of definitions of source code constructs to be generated based on specified elements of the model, the method further comprising monitoring the processing of the template in said code generator and storing a new mapping element each time a definition is processed, wherein different mapping elements specify a relationship between a definition and a corresponding element in said generated code, each mapping element storing a start line, end line, start column, and end column of the code generated by said definition, wherein said automatically changing the template is performed using the stored mapping elements to automatically change elements of the template if corresponding elements of the generated code are modified, wherein the modified code is designated as either manual or generated, wherein modified code designated as generated is used to automatically change the template to automatically produce said modified code, and wherein modified code designated as manual is not automatically generated by the template, wherein the modified code designated as generated is overwritten during subsequent code generation, and wherein modified code designated as manual is not overwritten during subsequent code generation and/or wherein the modified code is designated manual or generated through a graphical user interface, and wherein modified code designated as generated is displayed differently than modified code designated as manual in said graphical user interface and/or wherein the modified code is a new code element entered by a user, wherein the new code element is designated as manual, and wherein a protected region is inserted into the template and the modified code. receiving a template for generating code; receiving a model for generating code; processing the template and the model in a code generator, and in accordance therewith, generating code based on the model and the template; receiving a modification to the generated code, and in accordance therewith, producing modified code; and automatically changing the template based on the modified code to produce a modified template, wherein processing the modified template and the model in the code generator automatically generates said modified code, the method further comprising mapping one or more elements in said template to corresponding elements in said generated code, wherein the element in said template preferably caused the element in said generated code to be generated, wherein the template comprises a plurality of definitions of source code constructs to be generated based on specified elements of the model, the method further comprising monitoring the processing of the template in said code generator and storing a new mapping element each time a definition is processed, wherein different mapping elements specify a relationship between a definition and a corresponding element in said generated code, each mapping element storing a start line, end line, start column, and end column of the code generated by said definition, wherein said automatically changing the template is performed using the stored mapping elements to automatically change elements of the template if corresponding elements of the generated code are modified, wherein the modified code is designated as either manual or generated, wherein modified code designated as generated is used to automatically change the template to automatically produce said modified code, and wherein modified code designated as manual is not automatically generated by the template, wherein the modified code designated as generated is overwritten during subsequent code generation, and wherein modified code designated as manual is not overwritten during subsequent code generation and/or wherein the modified code is designated manual or generated through a graphical user interface, and wherein modified code designated as generated is displayed differently than modified code designated as manual in said graphical user interface and/or wherein the modified code is a new code element entered by a user, wherein the new code element is designated as manual, and wherein a protected region is inserted into the template and the modified code.