Domain Model Vs Persistence Model
The domain is the reason the application exists and everything gravitates around it.
Domain model vs persistence model. More control over your queries without necessarily relying on navigation properties to assemble your entity. It is the set of entities mapped to your database using an orm framework. Less time fighting orm to map your class model.
The end result was a model that neatly contains all of the behaviour required in our domain using constructors to specify what data was initially needed and easily recognisable domain oriented methods that specified what actions could be performed on the object. B use one model for both domain and persistence faster development bad domain encapsulation makes it easy to break domain rules. If you choose to keep separate domains however not only your domain model will be more expressive but your persistence will benefit from it too.
Persistence model pm for the sake of this article i am going to call the set of orm entities in a project the persistence model of that project. They have pretty different purposes. The mapping between them and the db is performed via an orm.
On the other hand persistence model will map one to one to database table and is the target of ef code first. Daos usually have a 1 to 1 correspondence with the underlying data store. A use a separate domain and persistence model will need to write some persistence code which can get challenging great domain encapsulation pure domain models.
The mapping between the domain model and the persistence model is performed manually in repositories. Domain model dm it is your domain entities. Domain models are usually persistent but i d like to separate the definition of an attempted domain model that ends up being anemic versus creating a persistent object model that is intentionally anemic because there is no need for anything more.
The next question is how do we save anything. Domain model for movies and superheroes note that superhero movies is a join table between the movie and superhero tables. The persistence model models what and how data is stored it models storage structure.