J88
J88

Reputation: 831

Editable System Parameters in Asp.NET MVC using EF?

What would be the best way to store parameters in an ASP.NET MVC application? I'm aware of the Web.config way of working but it just doesn't feel right to me , i'd rather put them in a 2 column table in a database so everything is easily editable.

I was thinking : would it be a good idea to create a modelclass with 2 properties : name & value. That way it would be easy to change these values in a backend-module etc..

Is this a proper way of doing things? Or does it have a lot of downsides ?

Thanks!

Upvotes: 0

Views: 87

Answers (1)

krilovich
krilovich

Reputation: 3505

I have worked on an application which had key/values both in the config and the database

One issue with keys in the config is the fact that if you want to make a change you have to update the web.config which forces a recompile. This sucks if you want to make a change on production during the day as users might lose some data.. this forces you to update during night time or to do some kind of scheduled maintenance window and let your users know

Database on the other hand you can make the change any time you want and the next time the user loads the particular page they will see the updated value, no need for a recompiling of the application :) The only downside here that i can think of is that you need to go into the production database and make changes, but if you are comfortable with that then this way is probably easier and less disruptive

In terms of security I think both are just as secure since one is on the DB server and one is on the WEB server.. Both of your windows servers should be equivalently secured and have SSL in place so one and so on and in the case of DB these days SQL 2016 comes with a ton of encryption options

These are just my 2 cents, there could obviously be more factors in play here

** EDIT

I personally can't think of any particular reason as to why NOT to use entity framework for this, EF is just a way to access data.... EF is mostly what I use for data access in my ASP.NET MVC apps and it is the one I am most used to so I might be somewhat biased in this. The table you would use for this would be used by entity framework in the same way that any other table would be used, with the fields probably being configKey, configValue, dateCreated?

Upvotes: 1

Related Questions