I'm using Entity Framework Code First
with ASP.NET MVC. This handles my database design based on the domain models within my application.
As it stands, the engine I'm writing will have a website
class and store
class. store
is a property of website
linked by a ForeignKey in the database. I want to implement some options like TaxDisplayType
on each of the models but am unsure on the best approach.
The issue I have is that Store
could potentially have the same option as website
which if it's set against the store should be used but default back to the website level if not.
These are the options I can think of to do this:
Add this option against each class i.e
Website.TaxDisplayType
andStore.TaxDisplayType
- I am worried about the amount of duplicated options between 2 tables.Have one table object that stores Key / Value pairs with a reference to the "scope" (i.e website or store) and I write a wrapper to drag out the options via their name. The issue I have with this approach is the use of magic strings. Unlike option 1, if a config option name is wrong in the code, it will still compile the project.
I'm also worried that going forward, if I have 500 options, this would equate to 500 database columns - This doesn't seem like a good idea.
I'm looking for some advice on the best way to handle this type of data given that:
- I'd like to use properties of classes rather than magic strings.
- Avoid duplication where possible.