I was looking for the answer to the same question and found that it's not too bad. However, instead of getting the EntitySet name, it's quite easy to use the same pluralizer.
In your text template, presumably at the top, add the following lines:
<#@ assembly name="System.Data.Entity.Design" #>
<#@import namespace="System.Data.Entity.Design.PluralizationServices" #>
This allows you to create a pluralizer instance as such:
<# PluralizationService pluralizer = PluralizationService.CreateService(System.Globalization.CultureInfo.CurrentCulture); #>
Then to pluralize an entity in the template, just use this:
<#=pluralizer.Pluralize(code.Escape(entity))#>
Of course, you can replace code.Escape(entity)
with the name of your variable storing the entity name.
And that's it!
Sources:
Are there any limitations on what libraries can be imported in a t4 template?
http://vthornheart.railsplayground.net/blog/archives/655