I am working on Desktop application in WPF and creating SqlRepository with LocalDB to store data. I am using following tools
I solved this error changing the initial project to the Entity Project.
Look:
Update-Database -Verbose Using StartUp project 'SCVE.Web'. <-- this ir error Using NuGet project 'SCVE.EntityFramework'.
PM>Update-Database
error and solution which I did today in 4 hours.
I am very much new in .net coding, but yes in PHP I have 10+ years experience.
It took me 4 hours to solve this.
1.My first Mistake:
I was not having Microsoft SQL Server 2019 in my laptop locally I was having this through AZURE which is not works for localhost, so I installed this locally after download, it took around 2 Hours.
2.Second changed mistake=
"DevConnection": "Server=localhost;Database=PaymentDetailDB;Trusted_Connection=True;MultipleActiveResultSets=True;"
then it works for me
I was able to solve this by adding parameters to the update-database command:
update-database -StartupProjectName MyApp.Web -ConnectionStringName MyAppConnectStringInWebConfig
As explained in other answers, the problem usually comes from having the wrong Initial project in Package Manager Console.
In my case the console was ignoring the value I selected in the Default Project drop down list, and also the -StartUpProjectName
parameter, and reproducing the wrong behavior of trying to connect to some default database engine, as Mikk's answer describes, in my case using a SqlExpress engine.
My problem was caused by a wrong solution configuration: if your solution has several projects and is meant to be run with the configuration option "Multiple startup projects", but you just downloaded it from your source code control repository, then it is possible that the default configuration option "Single startup project" is being applied to the solution (this config value usually is not checked-in in the source code control). In this case the Package Manager Console just ignores the startup project selected in its combo and just applies the default startup project in the solution, which may not have a connection string, as specified in Mikk's answer.
So I fixed it by changing the solution properties: Common properties
/ Startup project
/ Select Multiple startup projects
instead of Single startup project
, and after that the Package Manager Console would accept the Project name and update the right database.