- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我尝试为 Visual Studio 2017 执行 Razor ContosoUniversity(最初在 ContsoObserve 中重命名)并出现错误我的 .csproj 是
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.1" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.1" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Utils" Version="2.0.1" />
</ItemGroup>
<ItemGroup>
<PackageReference Update="Microsoft.NETCore.App" Version="2.0.4" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.1" />
</ItemGroup>
</Project>
我在 NuGet 中安装了所有这些包
当我
dotnet aspnet-codegenerator razorpage -m Student -dc SchoolContext -udl -outDir Pages\Students --referenceScriptLibraries
得到
Build FAILED. Data\SchoolContext.cs(5,17): error CS0234: The type or namespace name 'EntityFrameworkCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] Pages\About.cshtml.cs(5,32): error CS0234: The type or namespace name 'RazorPages' does not exist in the namespace 'Microsoft.AspNetCore.Mvc' (are you missing an assembly reference?) [C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] Pages\Contact.cshtml.cs(5,32): error CS0234: The type or namespace name 'RazorPages' does not exist in the namespace 'Microsoft.AspNetCore.Mvc' (are you missing an assembly reference?) [C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] Pages\Error.cshtml.cs(6,32): error CS0234: The type or namespace name 'RazorPages' does not exist in the namespace 'Microsoft.AspNetCore.Mvc' (are you missing an assembly reference?) [C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] Pages\Index.cshtml.cs(6,32): error CS0234: The type or namespace name 'RazorPages' does not exist in the namespace 'Microsoft.AspNetCore.Mvc' (are you missing an assembly reference?) [C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] Program.cs(7,28): error CS0234: The type or namespace name 'Hosting' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?) [C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] Program.cs(8,28): error CS0234: The type or namespace name 'Configuration' does not exist in the namespace 'Microsoft.Extensions' (are you missing an assembly reference?) [C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] Program.cs(9,28): error CS0234: The type or namespace name 'Logging' does not exist in the namespace 'Microsoft.Extensions' (are you missing an assembly reference?) [C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] Startup.cs(5,28): error CS0234: The type or namespace name 'Builder' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?) [C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] Startup.cs(6,28): error CS0234: The type or namespace name 'Hosting' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?) [C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] Startup.cs(7,28): error CS0234: The type or namespace name 'Configuration' does not exist in the namespace 'Microsoft.Extensions' (are you missing an assembly reference?) [C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] Startup.cs(10,17): error CS0234: The type or namespace name 'EntityFrameworkCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] Pages\About.cshtml.cs(9,31): error CS0246: The type or namespace name 'PageModel' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] Program.cs(39,23): error CS0246: The type or namespace name 'IWebHost' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] Data\SchoolContext.cs(10,34): error CS0246: The type or namespace name 'DbContext' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] Startup.cs(21,16): error CS0246: The type or namespace name 'IConfiguration' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] Pages\Contact.cshtml.cs(9,33): error CS0246: The type or namespace name 'PageModel' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] Startup.cs(33,31): error CS0246: The type or namespace name 'IApplicationBuilder' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] Startup.cs(33,56): error CS0246: The type or namespace name 'IHostingEnvironment' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] Data\SchoolContext.cs(16,16): error CS0246: The type or namespace name 'DbSet<>' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] Startup.cs(16,24): error CS0246: The type or namespace name 'IConfiguration' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] Pages\Error.cshtml.cs(10,31): error CS0246: The type or namespace name 'PageModel' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] Data\SchoolContext.cs(17,16): error CS0246: The type or namespace name 'DbSet<>' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] Data\SchoolContext.cs(18,16): error CS0246: The type or namespace name 'DbSet<>' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] Data\SchoolContext.cs(20,49): error CS0246: The type or namespace name 'ModelBuilder' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] Data\SchoolContext.cs(20,33): error CS0115: 'SchoolContext.OnModelCreating(ModelBuilder)': no suitable method found to override [C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] Pages\Index.cshtml.cs(10,31): error CS0246: The type or namespace name 'PageModel' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] Data\SchoolContext.cs(12,30): error CS0246: The type or namespace name 'DbContextOptions<>' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] 0 Warning(s) 28 Error(s) I try unload and reload project. Same result.
我补充 错误计数减少
Build FAILED.
Data\SchoolContext.cs(5,17): error CS0234: The type or namespace name 'EntityFrameworkCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] Pages\About.cshtml.cs(5,32): error CS0234: The type or namespace name 'RazorPages' does not exist in the namespace 'Microsoft.AspNetCore.Mvc' (are you missing an assembly reference?) [C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] Pages\Contact.cshtml.cs(5,32): error CS0234: The type or namespace name 'RazorPages' does not exist in the namespace 'Microsoft.AspNetCore.Mvc' (are you missing an assembly reference?) [C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] Pages\Error.cshtml.cs(6,32): error CS0234: The type or namespace name 'RazorPages' does not exist in the namespace 'Microsoft.AspNetCore.Mvc' (are you missing an assembly reference?) [C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] Pages\Index.cshtml.cs(6,32): error CS0234: The type or namespace name 'RazorPages' does not exist in the namespace 'Microsoft.AspNetCore.Mvc' (are you missing an assembly reference?) [C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] Startup.cs(10,17): error CS0234: The type or namespace name 'EntityFrameworkCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] Pages\About.cshtml.cs(9,31): error CS0246: The type or namespace name 'PageModel' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] Data\SchoolContext.cs(10,34): error CS0246: The type or namespace name 'DbContext' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] Pages\Contact.cshtml.cs(9,33): error CS0246: The type or namespace name 'PageModel' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] Pages\Error.cshtml.cs(10,31): error CS0246: The type or namespace name 'PageModel' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] Data\SchoolContext.cs(16,16): error CS0246: The type or namespace name 'DbSet<>' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] Pages\Index.cshtml.cs(10,31): error CS0246: The type or namespace name 'PageModel' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] Data\SchoolContext.cs(17,16): error CS0246: The type or namespace name 'DbSet<>' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] Data\SchoolContext.cs(18,16): error CS0246: The type or namespace name 'DbSet<>' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] Data\SchoolContext.cs(20,49): error CS0246: The type or namespace name 'ModelBuilder' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] Data\SchoolContext.cs(20,33): error CS0115: 'SchoolContext.OnModelCreating(ModelBuilder)': no suitable method found to override [C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] Data\SchoolContext.cs(12,30): error CS0246: The type or namespace name 'DbContextOptions<>' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\STR\source\repos\ContosoObserve\ContosoObserve\ContosoObserve.csproj] 0 Warning(s)
最佳答案
将您的包引用更改为 Microsoft.AspNetCore.All
(当前版本为 2.0.3)。这将包括 Entity Framework(加上您需要的内容)。
此外,不要在 PackageReference
元素上使用 Update
,请使用 Include
。
关于c# - 命名空间 'Microsoft 中不存在类型或命名空间名称 'EntityFrameworkCore',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48098261/
这是一个使用dotnet-ef迁移工具生成MySQL数据库的简单案例。 我有 Pomelo.EntityFrameworkCore.MySql 作为 MySQL DB 连接器和类属性: public
在使用EFCore加密SQLite数据库时,我遇到了这个GitHub issue 请参阅8月1日bricelam的评论。该问题说明了如何使用efcore加密SQLite数据库。 它指的是Microso
我有一个使用EF Core的ASP.NET Core 3.1 Web API应用程序。这是ConfigureServices类的Startup方法中的我的配置: services.AddDbConte
我很长一段时间都遇到麻烦。让我们想象一下这个例子: public class Coordinate { public int id {get;set;} public int x
我正在尝试将 mysql 与 Microsoft.EntityFrameworkCore 2.1-rc-final 和 MySql.Data.EntityFrameworkCore 8.0.11 一起
一个带有自动递增 Key 列的简单类 public class SomeClass { [Key] public long SomeClassId { get; set;} } 通常
我最近决定在我使用 ASP.NET Core MVC 开发的网站上实现 ASP.NET Identity 功能。 让我们快速浏览一下主题中的表和类: public class User : Ident
我有以下两个实体: public class Company { public Guid Id { get; set; } public string Name { get; set;
在学习 EntityFrameworkCore 上的其中一门 PluralSight 类(class)时,我从视频中看到了不同的结果。即,当调用 DbSet.AddRange(item 1, item
对于集成测试,我使用 EntityFrameworkCore SQLite 内存数据库并根据 Microsoft 文档创建其架构,但是当我尝试播种数据时,会引发异常该表不存在。 DbContext.D
我正在尝试 EntityFrameworkCore .我查看了文档,但找不到一种方法来轻松更新与另一个实体相关的复杂实体。 这是一个简单的例子。我有 2 个类 - 公司和员工。 public clas
加载相关数据(类(class)的类(class)页面)时出现以下错误。 错误 MySqlException: Unknown column 'c.Coursepages.CoursepageId' i
有没有办法使用 EntityFrameworkCore 将一个点转换为另一个 SRID? 之前我使用了 ST_Transform(ST_GeomFromText(@coord,4326),32661)
我正在尝试使用以下代码将我的 Web API 连接到 MySql 数据库: public class Startup { public void ConfigureServices
我正在使用 XUNIT 在点网核心应用程序中进行测试。 我需要测试一项服务,该服务在我的数据上下文中对 DbSet 进行内部异步查询。 I've seen here异步模拟 DbSet 是可能的。 我
我知道这是以前问过的那种问题,但我找不到有效的答案。 那么,是否有可能改变迁移的存储位置?我正在使用 EF Core。 仅供引用:我知道如果您移动第一个生成的迁移,接下来的迁移将放置在同一位置。 最佳
我正在尝试使用此命令安装 Microsoft.EntityFrameworkCore.Tools Install-Package Microsoft.EntityFrameworkCore.Tools
我尝试为 Visual Studio 2017 执行 Razor ContosoUniversity(最初在 ContsoObserve 中重命名)并出现错误我的 .csproj 是
我尝试为 Visual Studio 2017 执行 Razor ContosoUniversity(最初在 ContsoObserve 中重命名)并出现错误我的 .csproj 是
你好,我遇到了 Entity Framework 的问题,告诉我这些对象在我的数据库中不存在,而我已经使用 .ToTable 方法映射了名称。下面是我如何将上下文注入(inject)我的 Contro
我是一名优秀的程序员,十分优秀!