Hello, I intend to build a small microservice using Java, C#, and Python with 3
main table "Accounts", "Orders", and "Products". I have done a few small API projects with C# before, but I forget most of them.
Anyway, the OrderService is the C# one that I want to ask.
I intend to organize it like this:
//
OrderServiceSolution
OrderServiceProject
ControllerFolder
OrderServiceController
OrderServiceLib
ServiceFolder
RepositoryFolder
Entity(Object)Folder
//
Will this be ok? And since there is only one service, I don't need to use Generic Repository right?
What I have tried:
In addition, should I connect to the database using appsettings.json like this?
How do real projects connect to the database?
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
var builder = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
IConfigurationRoot configuration = builder.Build();
optionsBuilder.UseSqlServer(configuration.GetConnectionString("EStoreDB"));
}