5
I have an ASP.NET MVC project and I use web.config
to save some parameters that will be used by the system, but should not be changed by any user.
Now I have to implement some other parameters that can be changed by users, without having to restart the application (as happens when a change is made in the web.config
). I thought of the following solutions:
- Group the parameters by categories and create a table for each of them, placing a record where the columns would have the value of each category parameter, this record could be changed at any time.
But in this case I was a little uncomfortable having in a relational database (Microsoft SQL Server) independent tables with a single record in each. This could be considered a bad practice for evading the concept of relationship?
- Create a single table with two columns (
varchar
in both), one for the parameter name (unique in the table) and the other for the value. This table would play the role of myweb.config
and I could search the parameters by name.
This solution smells very bad! Because I can’t type the different values of the parameters and may have problems in a possible future migration of the database, or if someone ends up deleting the data.
I thought if there could be any solution, like Nosql for example, generating a file with data in the JSON structure that could store the different types of parameters, and can be changed at any time by users.
In ASP.NET MVC applications there is some option for this problem?
1. I don’t know what you’re considering a bad practice, but it’s a bad idea because each parameter will be a new table. Zero flexibility. 2. If you don’t need the type, there’s no reason to worry about it. If you need the type, this is a bad solution. "3". Nosql is nice, but using an entire database to save half a dozen parameters is a big exaggeration, don’t you think? Especially if you can just save these values in any JSON file. By the way, what’s the problem in creating a simple file?
– Jéf Bueno
By the way it seems to me that this question would only assume answers based mainly on opinions.
– Jéf Bueno
Your placements make a lot of sense @LINQ and in fact I can also use a simple file. Thank you so much.
– Jedaias Rodrigues