Entity Framework Core Generator tool supports several different ways to connect to the database.
Command Line Connection String
The database connection string can be passed in via command line using the
-c <ConnectionString> argument. Using the command line argument overrides all other connection strings.
Configuration Yaml file
The connection string can be stored in the configuration yaml file under the
Use the the
database/connectionString configuration with caution. You don't want to have a database user name and password stored in clear text when its committed to source control.
User Secret Manager
Entity Framework Core Generator supports reading the connection string from the user secrets file. The Secret Manager tool stores sensitive data in the user secrets file. User secrets are stored in a separate location from the project tree. The user secrets are associated with a specific user secret identifier. The user secrets aren't checked into source control.
Create a user secret with the
efg initialize command. The command will create a configuration yaml file if it doesn't exist, then it will update the user secret file with the supplied connection. Finally it will update the configuration yaml with a
userSecretsId if they aren't set.
To configure how Entity Framework Core Generator reads the user secret file, set the following in the configuration yaml file.
The connection string can also be store in the user secret file using the .NET Core
dotnet-user-secrets nuget tool.
userSecretsId can be shared with your .NET Core Project.
Read more about user secrets in the ASP.NET Core documentation