Usually, decouplingDecoupling roles and responsibilities is often a good practice. That being said, decoupling is often preceded by an increase in the complexity of the code base which could, in some cases, outweigh the benefits. NeverthelessSo, let's assume that this's notdecoupling is good up to a point. When it over-complicate the casedesign, becomes counterproductive.
You may be interested in the following patterns: MVC and, MVP and MVVM. Or in Onion Architectecture, depending on the size of the project. According to comments, looks like you already did choose MVVMapplication.
Now, the question boils down to
I was thinking about first rules and best practices and conventions
at the beginning of a project. I think it makes sense, don't use the
entities of Entity Framework in the view models.Instead of the EF
classes, I can use a "view" object. I want to define asa rule that in
presentation layer is better don't use EF classes
Law of Demeter may help you with the guidelines of yourthe code conventions. It's often introduced as a principle to design interoperatibilityinteroperability of components at low levels ofof abstraction. But It alsoit works for higher levels of abstraction.
Persistence Layer. Persistent entities live in and only in this layer. No domain business liveis implemented here. The componentsComponents at this level are in charge of retrieving and storing data into the different data storages. The persistent model here can be as simple as row mappers, Maps or arrays. The persistence data model is accessible only by upper layers through the proper abstractions. For example DAOs (DAOs, Entity Managers, etc.)
*Domain Layer *. The domain data model and its services live here. Theall the business rules happens in this layerlive here. Any need of persistencePersistence is delegated to the Persistence LayerPersistence Layer. The domain model never exposes persistence entities to upper layers. UpperUpper layers do have access to the domain model through the proper abstractions (repositories and domain services). For example Repositories or Domain Services. Usually, for simplicity, no DTO is needed yet. The domain is agnostic to the outer layers' needs of external layers. The mappings to DTOs and mappers should be carried bylocated in those who need itlayers that need'em. The domain entities don'tmodel doesn't necessarily match 1-to-1 the Persistence data model. Both can be different modelsThey have different concerns, hence they are different things.
Control Layer:. Controllers liveslive here and they are the bridge between UI and the domain model. TheThe access to the domain model is carrieddone through the proper abstractions (repositories, and services, etc). In order to prevent coupling between our domainUI and the consumer's domain model, controllers do map domain entities to another model. DTOs, POJOS, etc. DTOs are not View models don't live here. The reason is simple, howView Models belong to the view model should look like is UI concern.
Postel's law may help you too at taking decisions regarding interoperatibilityinteroperability among layers and tiers.
My advice is, don't you try a heavy decouplingdecouplings. There's going to be always a little coupling somewhere. Be flexible and KISS.
Following these and other principles (comventionsconventions, best practices, etc) should serve a real pruposepurpose. Apply them while they keep providing value to the application. Going to far in their implementations can be counterproductive. As I mentioned, the further you go, higher is the overall complexity. A solution
Remember that solutions should never be more complex than the problem it solvesproblems they solve (ideally).
KISS KISS and YAGNI are good "mantras"should help you out to keep always in mindremember this premise.