-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EF Core code-based model .. using a Data Dictionary approach ? #1370
Comments
@awbmansour could you elaborate a little more on the code you want to write. Do you want to still have CLR classes for each entity and just apply the same configuration to every CustomerId property? Or do you not want strongly typed classes and have more of a property bag (Dictionary<string, object>) approach? |
Dear Rowan, Thanks a lot for entertaining my humbled suggestion. My proposal is to have it in an object oriented way, with inheritance, so Assume that the dictionary associated with the context "mycontext" will be mycontext_globaldefs.cs would contain the properties that would be used [DisplayFormat(....)] Guid customer_id; [DisplayFormat(....)] string customer_name; In the individual entity classes, we will use these common properties along in customer.cs entity class file : namespace MyApp.Models
} In another class (eg, prioritycustomer.cs), where the property will be in prioritycustomer.cs entity class file : namespace MyApp.Models
} I hope I answered your kind question, Best Regards Adel On Sat, Jan 10, 2015 at 1:32 AM, Rowan Miller [email protected]
Thanks and Best Regards Adel Mansour simplerApps Software Solutions Ltd. mobile | viber | whatsapp : +20 122 3987214 |
@awbmansour - This can be achieved in EF6 using bulk configuration (a.k.a custom conventions).
Of course, if you wanted to parse some other format (such as the globaldefs.cs class you mentioned) and dynamically create conventions based on that it would be possible. We'll have something similar in EF7 too, tracked by #214. |
Wow .. this is awesome. I will need to learn more on this. Thanks a lot for your care and time during your busy schedule.
|
Closing out this issue now, feel free to re-open if you have further questions 😄 |
To explain what this is, consider the fact that if we have something like "Customer ID" property that is repeated some 40 times in 40 different model entities, that all refer to the same physical meaning, ie sharing the same common attributes such as Type, Display Format, Display Label, Validation, etc., then with a Data Dictionary approach this Property is defined Once with all its related attributes and then referred to as many as required in the model entities without the need to redefine the Attributes in each entity model file.
As it is now, we copy the Property with all its Attributes to all the Model files that need to have it, and this makes maintenance of the Model a nightmare each time we need to adjust, correct, or change an attribute of a property, we need to inspect all ViewModels and Models to see where else this property is mentioned.
The idea of Data Dictionary based development is not new (in the 1990's of object oriented 4GL development) proved to be a very productive and clean development environments.
Just a humbled thought I wanted to share.
The text was updated successfully, but these errors were encountered: