[Solved] dynamically add column to model and show relevant field to add, edit and delete the field data in view asp.net mvc enityframework?


You cannot “dynamically” add a column to a table per row. If the user could add a column, then that column would be added to the table in general, and every row in that table would have it. Even if this was possible, it would require granting your application admin rights on your database, which is a huge security faux pas. The database user exposed to the web should have only the most minimal privileges necessary: usually just INSERT, UPDATE, SELECT, and DELETE, and sometimes not even all of those. Anything more puts you at huge risk of SQL injection attacks and similar by malicious users. This is database 101 stuff, so it may behoove you to step back and learn more about the platform you’re developing on before proceeding.

It’s sounds like you’re basically just want something similar to a “settings” table. The way these things normally work is store the name of the “setting” and a value for that as a string. You might also store a type value, also as a string. Then, after you retrieve the setting you can coerce the value into the proper type you need it as. That’s really the best you can do with “dynamic” things, since a relational database is very much static. It needs to know the data and the types of that data it’s going to handle in advance.

2

solved dynamically add column to model and show relevant field to add, edit and delete the field data in view asp.net mvc enityframework?