-2

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.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • 1
    Just a hint: It would be way better, if you send the error message in english. Maybe you need to install a second language package on your pc and switch to it, to generate an english output. Otherwise maybe check https://es.stackoverflow.com/ – TheTanic Dec 05 '22 at 09:15

1 Answers1

0

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

  • Hi, Daniel i run the syntax in console but this show me next message: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SNI_PN11, error: 26 - Error Locating Server/Instance Specified) – David Paredes Dec 06 '22 at 02:33
  • @DavidParedes Okay there are a few problams that may happen: Did you made sure you have all nugets? , in the code i sent maybe your sql server is diffrent then mine , another problem is that your connection string Database name does not match the DB you trying to connect to – Daniel_543121 Dec 06 '22 at 10:15
  • Hi Daniel! sorry for the time but i can do it! I reinstall sql2019 and SSMS and before execute this code in the terminal : Scaffold-DbContext "Server=LAPTOP-xxxxx\SQLEXPRESS; DataBase=Prueba_ASP; Integrated Security=true;TrustServerCertificate=True" Microsoft.EntityFrameworkCore.SqlServer -OutPutDir Models – David Paredes Dec 13 '22 at 02:53