Need Help with a Minimal API
I am creating a simple API that takes in the values for a new microservice and stores them in a database --- eventually consumers will read the database entry and create the underlying infrastructure.
There will be 3 types of services, APIs, Cron Job and Consumers. APIs and Cron Jobs will have all of the same information, but consumers need additional information related to their infrastructure needs, so I created a separate model for the consumer that still inherits the base service model.
My questions:
does this approach make sense?
Since an API will always be a 1 for the ServiceType enum, how to do set that default value for consumers?
How do I create and store a dictionary? The topics should be the key and permissions the value
Thanks in advanced!
GitHub
InfraManager/Models/Consumer.cs at master · jessig1/InfraManager
Contribute to jessig1/InfraManager development by creating an account on GitHub.
4 Replies
Some of your terms are incorrect, you mention that
Consumers
inherits from Service
. Consumer has a reference to a service.
You're using entity framework which has a few different options of accomplishing the models you want.
Take a look at https://learn.microsoft.com/en-us/ef/core/modeling/inheritanceInheritance - EF Core
How to configure entity type inheritance using Entity Framework Core
You can use the entity framework fluent interface for setting default values as well. I'm on my phone right now, but I'll try and peek at the repo a bit later.
Thank you for clarifying! I'll do some digging into the fluent interface. The default value might not actually be that important as I believe I can have the client set that by the API is called.
My biggest question now is what is the bestway to handle a dictionary? Would EF be the best way to do that?
My biggest question now is what is the bestway to handle a dictionary? Would EF be the best way to do that?
At the end of the day ef is just a number of useful abstractions on sql.
Maintaining a set of key value pairs is fine in sql