Skip to content

Instantly share code, notes, and snippets.

@r1d3rzz
Last active February 21, 2025 08:41
Show Gist options
  • Save r1d3rzz/3f1b1ff3894b0d10a709c903e8a885d6 to your computer and use it in GitHub Desktop.
Save r1d3rzz/3f1b1ff3894b0d10a709c903e8a885d6 to your computer and use it in GitHub Desktop.
It looks like the `--use-database-names` option isn't being recognized in your `Scaffold-DbContext` command. This issue can sometimes occur due to the version of Entity Framework Core tools you're using or how the command is structured.
Here are a few steps to troubleshoot and resolve this:
1. **Ensure you have the latest version of EF Core tools**:
```powershell
dotnet tool update --global dotnet-ef
```
2. **Use the `dotnet ef` CLI command instead of the Package Manager Console**:
Open a command prompt or terminal in the root of your project and run:
```bash
dotnet ef dbcontext scaffold "Server=DESKTOP-test;Database=ReadCsv;User Id=test;Password=test;TrustServerCertificate=True;" Microsoft.EntityFrameworkCore.SqlServer --output-dir Models --use-database-names --table Users --table blabla --project //project-path.csproj
```
3. **Check your EF Core tools version**:
Make sure your project is using a compatible version of EF Core tools. You can specify the version in your `.csproj` file:
```xml
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="5.0.0" />
</ItemGroup>
```
4. **Verify the command syntax**:
Sometimes, using single quotes around the connection string can help:
```powershell
Scaffold-DbContext 'Server=DESKTOP-test;Database=ReadCsv;User Id=sa;Password=test;TrustServerCertificate=True;' Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models --use-database-names
```
If these steps don't resolve the issue, you might want to check for any specific version-related issues or updates in the official EF Core documentation.
Let me know if you need further assistance!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment