Imran Rizvi Imran Rizvi - 1 year ago 165
C# Question

How to add Serializable attributes in all entities generated by Entity Framework 5.0

I am using EF 5.0 to generate POCO entities and using it in a seperate Data Access layer

I want to tag all the entities [Serializable]

How to modify template to add Serializable attribute?

Answer Source

Following are the steps to do so:

1) Open the file

2) Locate following string in this file


3) Write [Serializable] above this line, so the code will look like this


Save the file , open the entity file, you can see that it has the desire tag written, you don't even have to generate entities again.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download