Alphapixel 182004
Alphapixel 182004

Reputation: 29

Trouble generating Entity Framework Core models from Azure SQL Database using dotnet ef dbcontext scaffold

I'm facing an issue when trying to generate Entity Framework Core models from an Azure SQL Database using the dotnet ef dbcontext scaffold command.

Connection String

Server=[server name].database.windows.net;Database=[database name];User ID=[username];Password=\"[password]\";Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;

Command Used

dotnet ef dbcontext scaffold "Server=[server name].database.windows.net;Database=[database name];User ID=[username];Password=\"[password]\";Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;" Microsoft.EntityFrameworkCore.SqlServer -o . --context-dir .

The words in [blocks] are filled with the correct private info.

Issue

When I run the command above, the console says:

Build started...
Build failed. Use dotnet build to see the errors.

When I run dotnet build, I get no errors, just 24 warnings

What I've Tried

Checked for build errors using dotnet build, but there are none. Adjusted the connection string and folder paths, but the issue persists. Connected to server using server address, username and password with sql server management studio and with sql server object explorer in Visual Studio

Environment

Upvotes: 1

Views: 271

Answers (2)

Alphapixel 182004
Alphapixel 182004

Reputation: 29

I was in the wrong directory, huge difference between "C:\Users\Nick\source\repos\Project Name" and "C:\Users\Nick\source\repos\Project Name\Project Name"

Upvotes: 0

Mateus Zampol
Mateus Zampol

Reputation: 203

Looks like 6.0.400 is an SDK version from August 2022

I would start by making sure you have the latest runtime and SDK for .NET 6

Upvotes: -1

Related Questions