Search code examples
.netasp.net-core.net-coreasp.net-web-apimicroservices

Microservices in .NET Core


I am working on microservices project in .NET Core which have a structure as given below project structure

In this solution, one is an API Gateway project, which is .NET Core project, and the rest projects under the folder 'microservices' are .NET Web API projects.

I have referenced this article: microservice-architecture-in-aspnet-core

In this article, they are working with different SQL Server databases for every microservice. I have only single database for all microservices.

Can anyone guide me in this scenario?

I would like to know where should I put my DbContext file and all the entities to use them in all microservices.

Thanks in advance.


Solution

  • I found solution for this question after some time of asking this question...

    Project structure

    You can add one class library project in that project you can put your DBContext, DBEntities and Models as shown in above project structure image.

    After that you can use them in your API projects by giving its reference.

    Thank you.