Search code examples
entity-framework-coreasp.net-core-mvcport

ASP.NET Core MVC : Selecting the controller


I created an ASP.NET Core MVC application with EF Core.

Several problems appeared one after the other. I eventually could create a controller on the orders table of Northwind database. It went with views automatically.

When launching the application, this opened the HomeController, that is provided by default.

As I want to open the OrdersController, in the address bar, after

https://localhost:7290/

I add orders, but I get a transient error, whereas the content has this property :

.UseSqlServer(
            @"Server=(localdb)\mssqllocaldb;Database=EFMiscellanous.ConnectionResiliency;Trusted_Connection=True",
            options => options.EnableRetryOnFailure(
                maxRetryCount: 5,
                maxRetryDelay: System.TimeSpan.FromSeconds(30),
                errorNumbersToAdd: null)
            );

I first tried with nothing in the parenthesis for EnableRetryOnFailure, and then tried something I saw in the forums. Well the example was on MySql, as I use SQL Server Express, perhaps good to know.

The database is on an instance of SQL Server Express rather than on localdb, but I am not sure this is the point.

I remember that the two controllers can target two ports, how do I verify that?

And supposing it is not the point either, what must I do?


Solution

  • As appears in the comments, my question was motivated by a false track, I wondered whether I had to use another port, but in fact the connection string was false. The platform automatically proposes a connection string after selecting a database in a list, but this connection string was false: it targeted localdb, whereas the database was on a SQL Server instance. After using the connection string that is provided by the server explorer, the results page still displayed an error, but no more the same one. "Order" is not a correct object name, this leads to think the connection is established, and I have to scan my application to situate an error on the object name. Maybe I shall open another thread.