Search code examples
c#asp.net-mvcmodel-view-controllerssmsnuget-package

Connection String Error "Missing its statement block"


I am using the updated Nuget Package Manager Console in Visual Studio to scaffold models from a database I've connected from named Sail. When I enter the connection string into the Package manager console.

PM> Data Source=localhost;Initial Catalog=Sail;Integrated Security=True

I receive the following errors:

At line:1 char:12
+ Data Source=localhost;Initial Catalog=Sail;Integrated Security=True;  ...
The Data section is missing its statement block.

Solution

  • Found my answer:The block below successfully generates models from the connected "Sail" SQL database.

    Scaffold-DbContext –Connection "Server(localdb)\mssqllocaldb;Database=Sail;Trusted_Connection=True;" 
    (localdb)\mssqllocaldb;Database=Sail;Trusted_Connection=True;" 
    -Provider "Microsoft.EntityFrameworkCore.SqlServer" -OutputDir "Models" –Context "Sail" –Verbose -Force