Answer the question
In order to leave comments, you need to log in
ASP MVC - Is it correct to use EntityFramework entities as a model for outputting data to a View?
Good afternoon.
There is a database with which I work through EF. There is an EF entity - ApplicationUser. There is a View page that displays a list of users (ApplicationUser).
Is it correct if I use the ApplicationUser type as the View model, which I will unload from the EntitytFramework and load onto the page?
Answer the question
In order to leave comments, you need to log in
Usually EF adds context to its entities, and as a result (theoretically) it will work slower and eat more memory.
Yes, and as a rule, all fields of an entity are not needed, but sometimes fields are needed that are not in entities.
Plus, if you need to add some field to the View, it will be easier to change the model and not the ef entity.
In short, nothing prevents using entities in the view, but this is not correct, it is better to create separate models for output.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question