I created a new ASP.NET Dynamic Data Entities Web Site project today, and I wanted to change the display name for the tables and the columns, as well as hide some of the columns. So, as I have done previously, I created a new class in the App_Code folder with the name of the entity, i wanted to decorate with the metadata in the form of attributes, as shown here
Public Class Countries_Metadata ... End Class Partial Public Class Country End Class
The only attribute in the above code is the DisplayName on the Countries_Metadata class, which is applied as metadata to the partial Country class. Now, the entity is named Country and the name of the code file is Country.vb. Yes, I’m working in VB for this project.
Now, this didn’t work, and I started to wonder if it had anything to do with the fact that I was using Visual Studio 2010 Beta and the .NET Framework 4 Beta for this project. Not so…
It turned out that the autogenerated file for the Entity Model added a namespace to the generated code, and I had simply forgotten to add it to Country.vb file, like this:
Namespace EDM Public Class Countries_Metadata ... End Class Partial Public Class Country End Class End Namespace