I had same error 'Code generated using the T4 templates...'. My issue was different than above. My database table schema was changed. Hence after refresh, I was editing the edmx by opening it as xml (rt click and say Open With... and select xml). After fixing all errors in xml, when I run the application, I get the above error. Hence next time I undo everything in TFS and continued by removing and adding problematic tables again from Edmx diagram page. Doing this way, helped resolve above error. Also learned, never to edit edmx file in xml mode.
Happy Coding.