I want to scaffold dbcontext efcore in .net 6 web API from Azure Sql Database

SURYA LAKKOJU 21 Reputation points
2022-11-29T20:09:16.923+00:00

Hello,

I have an issue, i'm trying to create models from my existing database which is a azure sql database. now when i run the below command it is giving me object reference not set to an instance error and I don't know what exactly I'm passing as null, one more thing we have azure ad authentication to access database with our accounts. no static passwords.

I have tried to run the below commands and none of them worked and gives me some sort of errors.

Scaffold-DbContext "Data Source=tcp:AzureTestdb.database.windows.net,1433;Authentication=Active Directory Default;Database=Department;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models

Scaffold-DbContext "Data Source=tcp:AzureTestdb.database.windows.net,1433;Authentication=Active Directory Integrated;Database=Department;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models

Scaffold-DbContext "Data Source=tcp:AzureTestdb.database.windows.net,1433;Authentication=Active Directory Interactive;Database=Department;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models

Scaffold-DbContext "Server=tcp:AzureTestdb.database.windows.net,1433;Initial Catalog=Department;Authentication=Active Directory Default;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=True;Connection Timeout=30;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models

can anyone please help me how to setup this scaffold in my visual studio to create models from azure sql database. below is the error i'm getting
265413-image.png

Please help me to scaffold the models, thanks in advance.

Entity Framework Core
Entity Framework Core
A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
696 questions
Azure SQL Database
{count} votes