According to MS Docs, Scaffold-DbContext
should accpect a optional parameter -Namespace
. However, seems that Scaffold-DbContext
cannot recognize this parameter. Did I miss something?
Command Error:
Scaffold-DbContext "Server=.\SQLExpress;Database=Stock;Trusted_Connection=True;User Id=sa;Password=P@ssw0rd;" Microsoft.EntityFrameworkCore.SqlServer -Namespace Stock.Models.DTO
Scaffold-DbContext : A parameter cannot be found that matches parameter name 'Namespace'.
At line:1 char:151
+ ... P@ssw0rd;" Microsoft.EntityFrameworkCore.SqlServer -Namespace Stock.M ...
+ ~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Scaffold-DbContext], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Scaffold-DbContext
Packages installed:
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational.Design" Version="1.1.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
-Namespace
works EF Core 5.0 onwards. your version is lower than that. Please upgrade EF Core