0

I have a 4 layers(project) Solution.

  1. Entity Framework Layer (EFL)
  2. Data Access Layer(DLL): All of CRUD operations and queries.
  3. Business Logic Layer(BLL): Calling DLL methods and adding some business to them.
  4. MVC Layer

As I said I have a separate EFL layer and because of this I don't know How can I use benefits of models in MVC? for example I can't write validation Annotations like <required> or <Display(Name:="username:")> in EFL layer because probably they will delete if I generate model from database again. and even if I do that How I can use Model folder of MVC?

If I create some class same as EFL classes I need to write a huge bunch of code to convert these classes to each other.

As what structure I can use MVC Models? and combine them with Entity Framework classes?

1
  • Yes you need to write Model classes in Model folder Commented Apr 8, 2016 at 8:52

2 Answers 2

1

The M in MVC is to me the view model. This means it contains the entities that are used in your views (which are optimized for those views); which are constructed in the controllers based on the entities you receive from your business layer, and which can look completely different than the view model entities.

Sign up to request clarification or add additional context in comments.

Comments

1

Think about the following questions:

  • How likely is it that you will change EF for some other persistence/ORM mechanism?
  • How likely is it that you will change to, or want to add another front-end technology?

If your answers are that those changes are likely, then you need to isolate framework-specifics. You might do this by having a series of base classes with the framework-neutral concepts in and then having framework-specific derivatives that can be added or removed as needed. E.g. EfCustomer or HibernateCustomerRepository.

If those changes are not likely, then I would question the value that a layered approach actually provides and I wouldn't be too concerned about decorating classes with framework-specific concepts. I would aim to keep things as simple and DRY as possible.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.