Error in Scaffold-DbContext - I can't create entities in NET 6.0

719 Views Asked by At

I have a problem when I try to connect to SQL Server database from my local PC. When I use this code in my terminal in Visual Studio 2022:

Scaffold-DbContext "Server=MyLaptop-xxxx/SQLEXPRESS; DataBase=db-example;Integrated Security=true" Microsoft.EntityFrameworkCore.SqlServer -OutPutDir Models

I get this error:

(provider: SSL Provider, error: 0 - La cadena de certificación fue emitida por una entidad en la que no se confía.)

I'm going to SQL Server Management Studio and try to see what the problem is, but I don't know what I can do when this information register in a LOG from Microsoft SQL Server Management Studio:

La configuración de permisos específico de la aplicación no concede el permiso Activación Local para la aplicación de servidor COM con CLSID {xxxxx-xxx-xxx-xxxx-xxxxxxxxxxxxxxx} y APPID {xxxxx-xxx-xxx-xxxx-xxxxxxxxxxxxxxx} al usuario LAPTOP-xxxx\user con SID (x-x-x-xxxxxxxxxxxxxxxxxx-xxx-xx) en la dirección LocalHost (con LRPC) que se ejecuta en el contenedor de aplicaciones con SID No disponible (No disponible). Este permiso de seguridad se puede modificar mediante la herramienta administrativa Servicios de componentes.

1

There are 1 best solutions below

3
Daniel_543121 On

Hi David try this run this syntax in your console package manger and make sure

to install all the required nugets

Scaffold-DbContext -provider Microsoft.EntityFrameworkCore.SqlServer -connection "Data Source=(localdb)\mssqllocaldb;" -Outputdir "Models" -ContextDir "Data" -DataAnnotations

That will also create you Folder with all the models and data folder with DbContext Class