admin管理员组文章数量:1188990
I have already added the related NuGet packages, as far as I know, to the following C# console project. However, I cannot use the corresponding namespace.
using Microsoft.EntityFrameworkCore.Migrations.Design;
Note: Dont Confuse it with Microsoft.EntityFrameworkCore.Design
Error:
Program.cs(2, 48): [CS0234] The type or namespace name 'Design' does not exist in the namespace 'Microsoft.EntityFrameworkCore.Migrations' (are you missing an assembly reference?)
Installed nuget packages list:
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.12" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.12">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.12" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.12" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.12">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
What am I missing?
I have already added the related NuGet packages, as far as I know, to the following C# console project. However, I cannot use the corresponding namespace.
using Microsoft.EntityFrameworkCore.Migrations.Design;
Note: Dont Confuse it with Microsoft.EntityFrameworkCore.Design
Error:
Program.cs(2, 48): [CS0234] The type or namespace name 'Design' does not exist in the namespace 'Microsoft.EntityFrameworkCore.Migrations' (are you missing an assembly reference?)
Installed nuget packages list:
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.12" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.12">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.12" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.12" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.12">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
What am I missing?
Share Improve this question edited Jan 25 at 16:29 Seyfi asked Jan 25 at 16:00 SeyfiSeyfi 1,9801 gold badge22 silver badges36 bronze badges 01 Answer
Reset to default 2From the Documents\PACKAGE.md doc:
By default, the package will install with
PrivateAssets="All"
so that the tooling assembly will not be included with your published app. For example:
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
If you want it at runtime, change the package reference to something like:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.1" />
</ItemGroup>
</Project>
版权声明:本文标题:entity framework core - Unable to Use `Microsoft.EntityFrameworkCore.Migrations.Design` in C# Project - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738352168a2079178.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论