EntityFramework + Sql Server + ASP.NET MVC

1
Hello, I have an ASP.NET MVC application that is using the ORM EntityFramework to communicate with a SQL Server database!

Currently I switched to a computer and had to install everything again, Visual Studio, and SQL Server Management. But when I start the application I would have to create the tables using migrations for SQL Server with the 'update-database' command. However, when I execute this command, the following error appears:

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: SQL Network Interfaces, error: 26 - Error Locating Server / Instance Specified)

Speaking that the base is not found. But my connectionString points exactly to the current database, because I got this connectionString from the Visual Studio connection itself through 'SQL Server Object Explorer'

ConnectionString

<connectionStrings>
    <add name="BWSDatabase" connectionString="Data Source=DESKTOP-PTI280V;Integrated Security=True;Persist Security Info=False;Pooling=False;MultipleActiveResultSets=False;Encrypt=False;TrustServerCertificate=True" providerName="System.Data.SqlClient" />
  </connectionStrings>

Does anyone have any idea what I should do? Thanks in advance ...

    
asked by anonymous 05.05.2018 / 00:25

1 answer

1

Everything is preferred ...

connection string has the machine name but does not have the instance name. Try to use localhost \ SQLEXPRESS in your Data Source, where you have SQLEXPRESS, in the example this is the name of your instance. But if I am not mistaken, it may just be the lack of the database parameter (" ..; Database = BWSDatabase; .. ").

The name of your instance there are simple ways to verify.

Accessing services.msc from the command prompt, you can see the name of your instance next to the service name.

Ifyouprefer,youcanseedirectfromManagementStudio...

Butbydefault,Iuse:

connectionString="Server=localhost\SQLEXPRESS;Database=BWSDatabase;User Id=sa;Password=senha;"
    
05.05.2018 / 02:12