3

In brief...

I'm trying to find a way to add some attributes to the properties in the classes created through the ADO.NET entity data model in a way that when I require updating of the database do not always have to add them manually.

Details ....

I created a class for creating a form that is dynamically filled with controls for editing properts. The input value is the object with public properties to edit. The output is a Control like panel control that contains dinamically created controls for properties editing. This concept can be easily applied on asp.net, Silverlight or classical stand alone applications.

Creating controls is based on the type of the property. For example if the property is some kind of integer data type, then the class creates a TextBox control. if it is Bool then creates a checkbox, if it is a key to referenced table than ComboBox is created or some other kind of external window to make a selection.

In some cases the data type is not sufficent to describe the content of the property and consequently I decided to use Attributes (C#).

My code is working perfectly but when the time for updating the source database comes (when I recreate the .edmx file) I loose all my Attributes and META-parameters.

I am wondering if somebody has an idea what to do to make this job more automated and simplified for maintenance.

Maybe extending the created classes is the solution but it is an additional job to do every time something on the source is changed.

Patrik
  • 1,286
  • 1
  • 31
  • 64

1 Answers1

2

You could use a metadata class for your entities and attach the properties to the metadata class instead

this article describes how to use metadataclass attributes for validation but once you know how to get hold of the attribute you should be able to use your existing code.

Rune FS
  • 21,497
  • 7
  • 62
  • 96
  • Yes I think it is the solution. Thank you. – Patrik Oct 17 '11 at 11:46
  • Please could you look at http://stackoverflow.com/questions/7868230/attaching-metadata-class-to-ado-net-entity-data-model-classes I did what you said but I still have a problem. – Patrik Oct 24 '11 at 09:23
  • @Patrik I see you have already found the solution. The code in the article I like to has a similar solution as you found yourself. Le me know if you get stucked again – Rune FS Oct 24 '11 at 15:56
  • The link doesn't work anymore => This domain has recently been listed in the marketplace. – Giu Jan 06 '15 at 21:00