One strange thing I should see in Entity Framework 4.0 V2 Auto Generated Classes (tt) is that classes are not marked as Serializable. Although they have a DataContract attribute for WCF.
Now the problem is that when I store the POCO object in the viewstate, it throws me an exception saying that the class is not serializable.
If I generate classes without t4 templates or using the defualt class generation scheme, then I see that the generated classes have the Serializable attribute on them.
But, unfortunately, I cannot use the default entity generation scheme. Since I want to post some custom logic for an auto-generated class, which is only possible with t4 templates.
Now I want to know:
1) Why the Serializable attribute does not exist in the auto-generated class, or am I making any mistake, or am I mistaken.
2) Is it good to configure the EF 4.0 T4 template to accommodate the Serializable attribute.
Look for your valuable suggestion.
Thank,
Burhan ghee
source
share