I inherited a .NET CORE project and have come across a setup I don't fully understand.
There is a DbContext
in the DAL with "Domiain" and "Entity" models e.g.
> DAL
> Models
> Domain
Person.cs
Car.cs
> Entity
PersonEntity.cs
CarEntity.cs
> Repositories
> PersonRepository.cs
> CarRepository.cs
And in each repository, the DbContext
is accessed to get the Person
model - which is immediately automapped like-for-like to the Entity
model
I cannot find any differences between the Entity and the Domain models - so what is the point? What situation would demand this setup?
I understand ViewModels
usage and abstracting to different models in a business logic layer but I can't think of an example where the repository commands would return or use a different model to the Domain
models given here.
Does anyone have any experience with this?
CodePudding user response:
You better look into Domain Driven Design (DDD). There are lots of references in understanding the concept and below are few.
References:
Basically, Domain are the actors in your application. They can perform certain actions (method calls) such as a Person can drive a car, a car can change its parts, etc. While Entity is your model when interacting with the database. You can combine those in a single class and it all depends on your preferred design. The concepts are what's important.
It seems that in your case the two were separated since method calls are not relevant to Entity Framework (DbContext). You will get to understand the code more as you go through it.
P.S. I know this question will be closed soon but I prefer not to place this in the comments.