【发布时间】:2020-07-08 11:28:12
【问题描述】:
我有一个项目在同一个解决方案资源管理器
中包含两个项目第一个:DbModelContextProvider(类库)
第二个:AppApiProvider(MVC核心api -v3.1.4)
我想创建一个控制器API Controller with actions, using Entity Framework自动生成代码系统Nuget但是不能生成有错误
错误:
there was an error running the selected code generator package restore failed rolling back pachage change for 'AppApiProvider'
我已经安装了Install-Package Microsoft.EntityFrameworkCore.Design -Version 3.1.4,但没有修复
然后在报价前搜索我的问题,但没有解决你的问题。 Quotation old
在startup.cs AppApiProvider项目中添加ConnectionString,并在appsettings.json中插入CS但不修复
startup.cs
services.AddDbContext<DB_iServiceContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
在 AppDbContext 中设置 connectionString OnConfiguring(DbContextOptionsBuilder optionsBuilder)
optionsBuilder.UseSqlServer("myConStr)
AppApiProvider.csproj
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\DbModelContextProvider\DbModelContextProvider.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.4" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" 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.IdentityModel.Tokens" Version="6.6.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.3" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.6.0" />
<PackageReference Include="Z.EntityFramework.Plus.EFCore" Version="3.0.51" />
<PackageReference Include="ZJA.Protection.Core" Version="1.0.0" />
</ItemGroup>
</Project>
【问题讨论】:
-
您好,能否分享一下您的.csproj文件(双击您的项目名称,会打开.csproj文件)?这个错误可能是版本错误造成的。
-
请查看我的报价更新
标签: c# asp.net-core-mvc class-library ef-core-3.0