I have a string property on an entity with a Max Length property of 13. I can easily assign a value with length 15 to this property and only find out when I try and save changes to the database. I can see no attributes on the generated property code that indicate a max length either. What is this field for and how do I use it?
+3
A:
see Field Max Length in Entity Framework
I had the same problem as you so I did that to get the value and apply it to my textbox or to validate...
moi_meme
2010-09-21 20:02:18
+1
A:
The Max Length and Fixed Length properties are ignored by the EF runtime. Do NOT expect the EF to automatically perform validation based on these properties.
These attributes are used by other consumers of the EDM, such as ASP.NET MVC 2.0 and ASP.NET Dynamic Data Controls, and, also for generating database scripts along with the StoreGeneratedPattern property.
Another usage for them would be when you are dealing at a lower level with EF; like when you are working with MetadataWorkspace class.
Morteza Manavi
2010-09-22 01:58:45