C# 命名空间.Net Core MVC中不存在该类型或命名空间
在我的.Net核心MVC项目中,我突然遇到了一个奇怪的错误。它告诉我:命名空间“MSPFrontend.Models”中不存在类型或命名空间名称“Tripmetadata”(是否缺少程序集引用?) 我有很多视图可以毫无困难地使用此文件夹中的模型。在myC# 命名空间.Net Core MVC中不存在该类型或命名空间,c#,razor,asp.net-core-mvc,C#,Razor,Asp.net Core Mvc,在我的.Net核心MVC项目中,我突然遇到了一个奇怪的错误。它告诉我:命名空间“MSPFrontend.Models”中不存在类型或命名空间名称“Tripmetadata”(是否缺少程序集引用?) 我有很多视图可以毫无困难地使用此文件夹中的模型。在my\u ViewImports.cshtml中,我有: @using MSPFrontend.Models Tripmetadata.cs 使用系统; 使用System.Collections.Generic; 使用System.Linq;
\u ViewImports.cshtml
中,我有:
@using MSPFrontend.Models
Tripmetadata.cs
使用系统;
使用System.Collections.Generic;
使用System.Linq;
使用System.Threading.Tasks;
使用System.Collections.Generic;
使用System.ComponentModel.DataAnnotations;
名称空间MSPFrontend.Models
{
公共部分类元数据
{
公共元数据()
{
Tripgpsdata=新哈希集();
Tripstate=新的HashSet();
}
[关键]
public int Tripid{get;set;}
[显示(Name=“开始时间戳”)]
公共long?Starttimestamp{get;set;}
[显示(Name=“结束时间戳”)]
公共long?Endtimestamp{get;set;}
公共长持续时间{get;set;}
[显示(Name=“平均速度”)]
公共十进制数?AvgSpeed{get;set;}
公共十进制?距离{get;set;}
公共虚拟ICollection Tripgpsdata{get;set;}
公共虚拟ICollection Tripstate{get;set;}
}
}
Tripmetadata.cs的名称空间是什么?你确定类Tripmetadata
是Public
?你能在Tripmetadata.cs
中显示代码吗?我已经为Tripmetadata添加了代码。csIt看起来像是Visual Studio出于某种奇怪的原因自行修复了错误。它不再出现。Tripmetadata.cs
的名称空间是什么?你确定类Tripmetadata
是Public
?你能在Tripmetadata.cs
中显示代码吗?我为Tripmetadata.csIt添加了代码。它看起来像是Visual Studio出于某种奇怪的原因自行修复了错误。它不再出现了。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace MSPFrontend.Models
{
public partial class Tripmetadata
{
public Tripmetadata()
{
Tripgpsdata = new HashSet<Tripgpsdata>();
Tripstate = new HashSet<Tripstate>();
}
[Key]
public int Tripid { get; set; }
[Display(Name = "Start Timestamp")]
public long? Starttimestamp { get; set; }
[Display(Name = "End Timestamp")]
public long? Endtimestamp { get; set; }
public long? Duration { get; set; }
[Display(Name = "Average Speed")]
public decimal? AvgSpeed { get; set; }
public decimal? Distance { get; set; }
public virtual ICollection<Tripgpsdata> Tripgpsdata { get; set; }
public virtual ICollection<Tripstate> Tripstate { get; set; }
}
}