Remove auto generate comments

不羁的心 提交于 2019-12-24 00:13:30

问题


I create some classes using Model First, EF4x as you can see a similar example in this answer from algreat.

My question is about the default comments that are generate as it shows in the block-quote below

//------------------------------------------------------------------------------
// <auto-generated>
//    This code was generated from a template.
//
//    Manual changes to this file may cause unexpected behavior in your application.
//    Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

Is there a way to avoid the creating of those comments? or remove them all?


回答1:


If you open your EDMX model, you can right click and choose "Add code generation item"
This will add a T4 template to your project (which is the same as the default template of your EDMX model). If you take a look at the code behind this template, you will find the comments. You can just remove them and save the template and your code will be generated without the comments.

The part you refer to actually looks like this in the template

//------------------------------------------------------------------------------
// <auto-generated>
// <#=GetResourceString("Template_GeneratedCodeCommentLine1")#>
//
// <#=GetResourceString("Template_GeneratedCodeCommentLine2")#>
// <#=GetResourceString("Template_GeneratedCodeCommentLine3")#>
// </auto-generated>
//------------------------------------------------------------------------------


来源:https://stackoverflow.com/questions/14942636/remove-auto-generate-comments

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!