DEV Community

Discussion on: REST API versioning with ASP.NET Core

Collapse
 
hdsoftware profile image
HD Software

Question about versioning the datamodel
Lets say you have an API that use AutoMapper on a datamodel.
Now, if the datamodel changes, the API will still compile like nothing happend, but the end result wil not be compatible anymore

I see two different ways out of this:

1:
Project
- DTO
- V1
PersonDTO
- V2
PersonDTO
2:
Project
- DTO
PersonDTO_V1
PersonDTO_V2

What would be considered best practice here?

Collapse
 
hdsoftware profile image
HD Software

Just figured it out myself by testing
Adding version to the ClassName is best because else having USING statements to support multiple versions in the same API class wil create problems if ClassNames are the same