Reputation: 2938
I have a table with CreatedBy
ModifiedBy
and Isactive
columns. Using Entity Framework Database first renders all the fields in create, detail and list views. I am automatically creating views by using "MVC 5 Controller with views, using Entity Framework" option.
I want views to don't show these fields and assign values in controller to it. I already tried [ScaffoldColumn(false)]
but it works only with @Html.DisplayForModel()
What should i do to achieve this?
Upvotes: 0
Views: 4738
Reputation: 3217
I would recommend to use ViewModels. That means you can map your db poco entity to physical representation of your View (known as ViewModel). Then, you can show whatever you want. When you do not want to update some columns, you can hide it using CSS or make it just read only. On your controller side (update action) you just read properties you want to update.
I recommend to follow this topics to get to know more about VM: What is ViewModel in MVC?
Upvotes: 1