问题
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