Initialize EF Core DbContext for an ASP.NET Core project using EF Core Power Tools CLI. Use when the user wants to scaffold a database context, generate entity models from an existing database, or set up Entity Framework Core with connection strings and dependency injection.
Install
npx skillscat add jim60105/copilot-prompt/initialize-ef-core-dbcontext Install via the SkillsCat registry.
Initialize EF Core DbContext
Set up Entity Framework Core DbContext using EF Core Power Tools CLI.
Pre-requisite
- Ensure the Git working tree is clean:
If the working directory is not clean, stop execution.git status
Steps
Use EF Core Power Tools CLI to generate the DbContext:
efcpt "Server=(localdb)\MSSQLLocalDB;Initial Catalog=ContosoUniversity;Trusted_Connection=True;Encrypt=false" mssqlNote: Use the correct connection string according to the project requirements.
Run
dotnet buildto verify everything compiles.Configure
Program.csfor DI andappsettings.jsonfor connection strings. Referenceefcpt-readme.mdfor instructions. Ensure necessary namespaces are used.Run
dotnet buildto verify everything compiles.