C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,462 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello,
In a WPF MVVM application, I'm using a layered architecture:
Currently, I use EF entity classes directly in my service methods and ViewModel properties.
Example:
public class BookService
{
public Book GetById(int id); // using EF entity
}
public class BookViewModel
{
public Book SelectedBook { get; set; } // also EF entity
}
I want to avoid tight coupling between layers.
✅ What is the best way to replace EF entities in the ViewModel layer without breaking the architecture?
• Should I use DTOs in the service layer and map them manually or with a tool like AutoMapper?
• Is there a recommended lightweight method to map between EF entities and DTOs for simple CRUD apps?
Thanks in advance.