开发环境:
请参阅http://www.npgsql.org/efcore/index.html
这是.csproj内容:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Folder Include="wwwroot\" />
<Folder Include="SQL Scripts\" />
<Folder Include="Models\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="2.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.0.0" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL.Design" Version="2.0.0-preview1" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />
</ItemGroup>
</Project>
从.csproj内容中,请注意“Npgsql.EntityFrameworkCore.PostgreSQL.Design”的版本。它是“2.0.0-preview1”。 “2.0.0”没有nuget包。
当我尝试发出命令对现有的postgreSQL数据库进行反向工程时,我遇到以下消息:
Version for package `Microsoft.VisualStudio.Web.CodeGeneration.Tools` could not be resolved.
这是我用来对现有数据库进行逆向工程的清理命令行:
dotnet ef dbcontext scaffold "Host=localhost;Database=mydatabase;Username=me;Password=mypwd" Npgsql.EntityFrameworkCore.PostgreSQL
Microsoft.VisualStudio.Web.CodeGeneration.Tools包的版本是2.0.0版。
我的nuget设置如下:
非常感谢任何帮助。
答案 0 :(得分:1)
一些注意事项:
答案 1 :(得分:0)
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Folder Include="wwwroot\" />
<Folder Include="SQL Scripts\" />
<Folder Include="Models\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="2.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.0.0" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" />
</ItemGroup>
</Project>