Overview Version History Q & A Rating & Review
.NET DbContext Generator
A VS Code extension that automates the creation and configuration of Entity Framework Core DbContext for .NET applications, including SQL Server, MySQL, and SQLite setup.
Features
🚀 Automatic DbContext Generation : Creates a complete DbContext from your model classes
🛠 Multi-Database Support : Configures for SQL Server, MySQL, or SQLite
🔄 Model Management : Add individual models or regenerate entire DbContext
⚙ Complete Setup : One command to generate DbContext and configure Program.cs
📝 Connection Strings : Automatically creates/updates appsettings.json
🔍 Custom Code Preservation : Maintains your manual code during regeneration
Installation
Open VS Code
Go to Extensions (Ctrl+Shift+X
)
Search for ".NET DbContext Generator"
Click Install
Commands
Command
Description
Shortcut
Generate DbContext
Creates DbContext from models
-
Configure DbContext
Adds DbContext to Program.cs
-
Add Model to DbContext
Adds single model to existing DbContext
-
Regenerate DbContext
Updates DbContext while preserving custom code
-
Complete DbContext Setup
Runs all setup steps automatically
Ctrl+Alt+D
Usage
Basic Setup
Create your model classes in the Models
folder
Run the Complete DbContext Setup
command
Select your database provider (SQL Server, MySQL, or SQLite)
The extension will:
Generate AppDbContext.cs
Configure Program.cs
Update appsettings.json
Suggest required NuGet packages
Adding New Models
Create your new model class
Run Add Model to DbContext
Select your model from the list
Configuration Options (optional if you need)
Add these to your VS Code settings.json
:
{
"dotnetDbContextGenerator.modelsDirectory": "Models",
"dotnetDbContextGenerator.dataDirectory": "Data",
"dotnetDbContextGenerator.dbContextName": "AppDbContext",
"dotnetDbContextGenerator.includeOnModelCreating": false,
"dotnetDbContextGenerator.useLazyLoading": false,
"dotnetDbContextGenerator.usePluralization": true
}