I have a new ASP.NET core Web API application based on .NET 6 which shares the domain models with the Sitecore ASP.NET MVC application using .NET Framework 4.7.2 (legacy code). I want them to communicate with each other via Web API and the same models should be used for that. We wanted to create a new nuget package but unfortunately because of different .NET versions this is not compatible. Is there any way to not duplicate the models in both project but extract them somehow and reuse in both?
CodePudding user response:
Yes, you can.
Create Class Library (.NET Standard 2.0)
and put your models.
then reference 2 project to this class library.
CodePudding user response:
Yes - create a class library targetting ".NET Standard 2.0" which contains your domain model classes.
It can be used in both .NET 4.7.2, as well as .NET 6 projects.