Menu

Configuring the AutoMapper property binding behaviour

When you map ViewModels to Entity model its not always one-to-one.

For example showing an item in the database in a details view can be one-to-one,  but when you think about the POST – ViewModel from client to Controller does not need to have the Primary key. And on PUT you don’t want the created by overwritten with any thing. You get my point.

If you want to keep the destination value on map you need to initialse mapping like this.

So in your PUT can be like this

Post can be like this

 

Leave a comment