samedi 9 mai 2020

C# Entity Framework / ASP.NET REST and Models Design Pattern or Solution Architecture

I am developing a .NET 4.0 Windows Service. This Windows service (it must be .NET 4.0) makes a data exchange via REST with an ASP.NET Web API .NET 4.5. The data storage is in a SQL Server. I have decided to make the data access via Entity Framework 6 (.NET 4.5). Now I have a question regarding the model required by the Entity Framework and the .NET Windows Service. If I use Code-First, it works -> i can reference the Model from the Windows Service Project and also from the Entity Framework Project. When I choose database-first, the Entity Framework generates the model classes based on the database and I don't have a dedicated .NET 4.0 assembly with the model classes that i can reference in the .NET 4.0 Windows Service project. I could create an additional .NET 4.0 assembly and define the model classes in there a second time, but this is very tedious and time consuming.

Every square on the following drawing is a separate project. on the second illustration -> the .NET 4.0 Windows Service knows nothing about the model so i can not deserialize the JSON to objects.

i tried to illustrate this

Any hints?

Aucun commentaire:

Enregistrer un commentaire