即使安装了工具,也无法运行.net ef

时间:2018-05-06 11:40:59

标签: xamarin asp.net-web-api2 asp.net-core-2.0 ef-core-2.0

我正在尝试让ef核心在xamrian中运行,并且我遇到了一些dotnet命令没有运行的问题。我已经按照另一个方式添加了这些工具,但是没有用。

这是我的第一次迁移,我的连接搅拌设置在

的application.json中
  

“ConnectionStrings”:{       “DefaultConnection”:“数据源=开发者\ SAGESQL2014;初始   目录= CallManagment;集成   Security = True; MultipleActiveResultSets = True“}}

这是我感谢你的帮助。

  

dotnet ef迁移添加InitialMigration dotnet:找不到可执行文件   匹配命令“dotnet-ef”在行:1 char:1   + dotnet ef迁移添加InitialMigration   + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~       + CategoryInfo:未指定:(无可执行文件...和“dotnet-ef”:字符串)[],RemoteExcept离子       + FullyQualifiedErrorId:NativeCommandErro

这是我目前的项目文件

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netcoreapp2.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <None Remove="appsettings.json" />
  </ItemGroup>

  <ItemGroup>
    <Content Include="appsettings.json">
      <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
    </Content>
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.0.2" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.0.2" />
  </ItemGroup>

  <ItemGroup>
    <Reference Include="System">
      <HintPath>System</HintPath>
    </Reference>
  </ItemGroup>

</Project>

编辑2显示已添加的组件。

enter image description here

编辑3

显示根据以下建议所做的更改仍无效。

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netcoreapp2.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <None Remove="appsettings.json" />
  </ItemGroup>

  <ItemGroup>
    <Content Include="appsettings.json">
      <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
    </Content>
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.0.2" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.0.2" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.0.2" />

  </ItemGroup>
    <ItemGroup>
   <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.2" />
</ItemGroup>
  <ItemGroup>
    <Reference Include="System">
      <HintPath>System</HintPath>
    </Reference>
  </ItemGroup>

</Project>

1 个答案:

答案 0 :(得分:1)

您是否尝试在Package Manager控制台内运行?如果是这样,您需要cd到项目目录。另外,如果您在PMC内部,为什么不使用EF Core PMC tools

相关问题