0

I am new to MVC. I am a developer that uses Web Forms and Windows Forms (not through choice).

I have created a simple MVC4 app, which connects to an SQL database using Entity framework (database first).

There is a model class created by the entity framework (under the .edmx heading) called PersonModel.tt. Does this mean that I do not have to create any model classes in the model folder (which is created automatically when you create an MVC 4 app). Is the model folder only suppose to be used when you do not use the Entity Framework?

w0051977
  • 15,099
  • 32
  • 152
  • 329
  • I am not 100% sure if I get the question, but keep in mind the separation of concerns. You should have your view models, which represents the information needed by/for a view/controller and the Entity Framework entities which represents your database model. One view model is not necessary related to a Entity Framework database entity. – gustavodidomenico Nov 11 '15 at 17:30
  • @gustavodidomenico, thanks. Is the model folder specifically for View Model classes? – w0051977 Nov 11 '15 at 17:33
  • 1
    @w0051977, yes. I would consider to create a library project for your database model and entity framework stuff, keep the MVC Application as simple as possible. Another strong suggestion, avoid to reference the entities in your view models, try to flatten the information whenever is possible. (Check the AutoMapper framework to perform it automatically). – gustavodidomenico Nov 11 '15 at 17:37

0 Answers0