防止visual studio将setter方法限制为内部

好吧,我使用visual studio 2015 CE,更新2.我通常做的一个生产力黑客是我创建空模型类,如:

public class PersonModel { } 

然后在选择表达式中使用它们,如:

 db.People.Where(p => someCondition) .Select(p => new PersonModel { Id = p.Id, Name = p.Name, //set other properties }).ToList(); 

然后我转到尚未存在的属性IdName ,…并按Control+. 要求v​​isual studio为我generate property Id 。 一切都很好,但它会创造:

 public int Id { get; internal set; } 

如果我在asp.net webapi模型绑定中使用相同的方法,绑定将无提示失败并给我Id = 0

所以我的问题是:有没有选择让VS创建公共setter,即:

 public int Id { get; set; } 

您可以通过键入prop并按两次TAB来完成此操作。 它将要求您输入属性的类型和名称,但不会从现有属性中提取它。

最好的祝福。