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 0
Add a comment  | 

1 Answer 1

Reset to default 2

From 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 coreUnable to Use MicrosoftEntityFrameworkCoreMigrationsDesign in C ProjectStack Overflow