Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/322.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-core/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# System.InvalidOperationException:&x27;财产';描述列表';不是实体类型为';候选人';_C#_Asp.net Core - Fatal编程技术网

C# System.InvalidOperationException:&x27;财产';描述列表';不是实体类型为';候选人';

C# System.InvalidOperationException:&x27;财产';描述列表';不是实体类型为';候选人';,c#,asp.net-core,C#,Asp.net Core,我现在遇到了这个错误,但不久前应用程序运行良好,我只在模型中添加了数据,但它没有在候选历史中使用。 我真的不明白为什么它会给我这个错误,因为我没有更改历史控制器上的任何内容,只是向其他控制器使用的候选模型添加了数据 这是我的应用程序上下文: using HCCBPOHR.Core.Contracts.Data; using Microsoft.AspNetCore.Identity.EntityFrameworkCore; using Microsoft.EntityFrameworkCore

我现在遇到了这个错误,但不久前应用程序运行良好,我只在模型中添加了数据,但它没有在候选历史中使用。 我真的不明白为什么它会给我这个错误,因为我没有更改历史控制器上的任何内容,只是向其他控制器使用的候选模型添加了数据

这是我的应用程序上下文:

using HCCBPOHR.Core.Contracts.Data;
 using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.Extensions.Configuration;
using System;
 using System.Collections.Generic;
 using System.IO;
 using System.Linq;
 using System.Text;


namespace HCCBPOHR.Data.Context
 {


    public class ApplicationContext : IdentityDbContext<ApplicationUser>
{
    protected IConfiguration _Configuration;

    public IConfiguration Configuration 
    {

        get
        {
            if (_Configuration == null)
            {
                var builder = new ConfigurationBuilder()
                .SetBasePath(Directory.GetCurrentDirectory())
                .AddJsonFile("appsettings.json");

                _Configuration = builder.Build();
            }

            return _Configuration;
        }
        set
        {
            _Configuration = value;
        }
    }
    public ApplicationContext(DbContextOptions<ApplicationContext> options) : base(options)
    {
    }

    public ApplicationContext()
    {
    }

    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
    {
        var connectionString = Configuration.GetConnectionString("DefaultConnection");

        optionsBuilder.UseSqlServer(connectionString);

    }

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        foreach (var relationship in modelBuilder.Model.GetEntityTypes().SelectMany(e => e.GetForeignKeys()))
        {
            relationship.DeleteBehavior = DeleteBehavior.Restrict;
        }
        ConfigAsset(modelBuilder);

        base.OnModelCreating(modelBuilder);
    }

    private void ConfigAsset(ModelBuilder modelBuilder)
    {

    }

    public DbSet<ApplicationUser> ApplicationUsers { get; set; }
    public static IEnumerable<object> ApplicationUser { get; internal set; }
    public DbSet<Profile> Profile { get; set; }
    public DbSet<Ads> Ads { get; set; }
    public DbSet<Area> Area { get; set; }
    public DbSet<Candidate> Candidates { get; set; }
    public DbSet<CandidateAnalytics> CandidateAnalytics { get; set; }


}

}
这也是我的看法:

@model HCCBPOHR.Data.Candidate

@{
ViewData["State"] = "CandidateHistory";
 }
<h2>Canidate - @Model.Name</h2>
<label>History</label>
 <hr />
<div class="panel panel-default">
<div class="panel-heading">
    <i class="fa fa-clock-o fa-fw"></i> History Of @Model.Name
</div>
<div class="panel-body">
    @foreach (var Description in Model.DescriptionList)
    {
        @if (Description.Saving == true)
        {
            <ul class="timeline">
                <li class="timeline">
                    <div class="timeline-badge">
                        <i class="fa fa-check"></i>
                    </div>
                    <div class="timeline-panel">
                        <div class="timeline-heading">
                            <h4 class="timeline-title">@Description.State</h4>
                            <p>
                                <small class="text-muted"><i class="fa fa-clock-o"></i> @Description.DateOfDescription.ToShortDateString()</small>
                            </p>
                        </div>
                        <div class="timeline-body">
                            <p><b>Description:</b> @Description.Description</p>
                        </div>
                        <div class="timeline-body">
                            <p><b>Interviewer:</b> @Description.Interviewer</p>
                        </div>
                        <div class="timeline-body">
                            <p><b>Feedback:</b> @Description.Feedback</p>
                        </div>
                        <div class="timeline-body">
                            <p><b>FeedbackDate:</b> @Description.FeedbackDate</p>
                        </div>
                        <div class="timeline-body">
                            <p> <b>Bad behavior:</b> @Description.Behavior</p>
                        </div>
                        <div class="timeline-body">
                            <p> <b>Applied For:</b> @Description.SelectedAd</p>
                        </div>
                    </div>
                </li>
            </ul>
        }
        @if (Description.Saving == false)
        {
            <ul class="timeline">
                <li class="timeline-inverted">
                    <div class="timeline-badge">
                        <i class="fa fa-check"></i>
                    </div>
                    <div class="timeline-panel">
                        <div class="timeline-heading">
                            <h4 class="timeline-title">@Description.State</h4>
                            <p>
                                <small class="text-muted"><i class="fa fa-clock-o"></i> @Description.DateOfDescription.ToShortDateString()</small>
                            </p>
                        </div>
                        <div class="timeline-body">
                            <p><b>Description:</b> @Description.Description</p>
                        </div>
                        <div class="timeline-body">
                            <p><b>Interviewer:</b> @Description.Interviewer</p>
                        </div>
                        <div class="timeline-body">
                            <p><b>Feedback:</b> @Description.Feedback</p>
                        </div>
                        <div class="timeline-body">
                            <p><b>FeedbackDate:</b> @Description.FeedbackDate</p>
                        </div>
                        <div class="timeline-body">
                            <p> <b>Bad behavior:</b> @Description.Behavior</p>
                        </div>
                        <div class="timeline-body">
                            <p> <b>Applied For:</b> @Description.SelectedAd</p>
                        </div>
                    </div>
                </li>
            </ul>
        }
    }
   </div>
 </div>
  <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal" data-whatever="@Model.Saving"> Add History Description</button>
  <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
    <div class="modal-content">
        <div class="modal-body">
            <form asp-action="CandidateHistory">
                <div asp-validation-summary="ModelOnly" class="text-danger"></div>
                <div class="form-group">
                    <label>Estado</label>
                    <select asp-for="State" class="form-control">
                        <option value="FirstIntrerview">First Interview </option>
                        <option value="SecoundInterview">Secound Interview</option>
                        <option value="Contract">Contract</option>
                    </select>
                </div>
                <div class="form-group">
                    <label asp-for="InterViewDate" class="control-label">Interview Date:</label>
                    <input asp-for="InterViewDate" class="form-control" value="" />
                    <span asp-validation-for="InterViewDate" class="text-danger"></span>
                </div>
                <div class="form-group">
                    <label asp-for="Description" class="control-label">Description</label>
                    <input asp-for="Description" class="form-control" value="" />
                    <span asp-validation-for="Description" class="text-danger"></span>
                </div>
                <div class="form-group">
                    <label>Side of History</label>
                    <select asp-for="Saving" class="form-control">
                        <option value="false">Candidate </option>
                        <option value="true">Hitachi</option>
                    </select>
                </div>
                <div class="form-group">
                    <label>Interviewer</label>
                    <select asp-for="Interviewer" class="form-control">
                        <option value="Mananger">Mananger </option>
                        <option value="Diretora">Diretora</option>
                    </select>
                </div>
                <div class="form-group">
                    <label>FeedBack</label>
                    <select asp-for="Feedback" class="form-control">
                        <option value="Yes">Yes </option>
                        <option value="No">No</option>
                    </select>
                </div>
                <div class="form-group">
                    <label asp-for="FeedbackDate" class="control-label">Feedback Date:</label>
                    <input asp-for="FeedbackDate" class="form-control" value="" />
                    <span asp-validation-for="FeedbackDate" class="text-danger"></span>
                </div>
                <div class="form-group">
                    <label>Bad Behavior?</label>
                    <select asp-for="Behavior" class="form-control">
                        <option value="Yes">Yes </option>
                        <option value="No">No</option>
                    </select>
                </div>
                <div class="form-group">
                    <label asp-for="DateOfDescription" class="form-group">Date of the HistoryPost</label>
                    <input asp-for="DateOfDescription" class="form-group" />
                    <span asp-validation-for="DateOfDescription" class="text-danger"></span>
                </div>

                <div class="form-group">
                    <input type="submit" value="Create" class="btn btn-default" />
                </div>
            </form>
        </div>
        <div class="modal-footer">
            <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
        </div>
    </div>
   </div>
 </div>
@model HCCBPOHR.Data.Candidate
@{
ViewData[“状态”]=“候选历史”;
}
Canidate-@Model.Name
历史

@Model.Name的历史记录 @foreach(Model.DescriptionList中的var描述) { @如果(Description.Saving==true) {
  • @说明.国家 @Description.DateOfDescription.ToShortDateString()

    Description:@Description.Description

    采访者:@Description.concert

    反馈:@Description.Feedback

    反馈日期:@Description.FeedbackDate

    不良行为:@Description.behavior

    申请者:@Description.SelectedAd

} @if(Description.Saving==false) {
  • @说明.国家 @Description.DateOfDescription.ToShortDateString()

    Description:@Description.Description

    采访者:@Description.concert

    反馈:@Description.Feedback

    反馈日期:@Description.FeedbackDate

    不良行为:@Description.behavior

    申请者:@Description.SelectedAd

} } 添加历史记录描述 埃斯塔多 第一次面试 第二次面试 合同 面试日期: 描述 历史的一面 候选人 日立 采访者 管理者 迪雷托拉 反馈 对 不 反馈日期: 不良行为? 对 不 历史邮递日期 接近
以下是我的候选模型:

 public class Candidate : BaseEntity
{
    public int Id { get; set; }
    public string Name { get; set; }
    public int Number { get; set; }
    public string ProfileText { get; set; }
    public Byte[] CV { get; set; }
    public string CVNAME { get; set; }
    public List<Profile> ProfileList { get; set; }
    public string Title { get; set; }
    public String Description { get; set; }
    public Boolean Saving { get; set; }
    public string State { get; set; }
    public DateTime DateOfDescription { get; set; }
    public List<Candidate> DescriptionList { get; set; }
    public DateTime FeedbackDate { get; set; }
    public string Feedback { get; set; }
    public String Interviewer { get; set; }
    public DateTime InterViewDate { get; set; }
    public string Behavior { get; set; }
    public List<Ads> AllAds { get; set; }
    public string SelectedAd { get; set; }
    public int Vacancies { get; set; }
    public List<Candidate> VacanciesFilled { get; set; }
    public int GivenUp { get; set; }
    public int Age { get; set; }
    public Candidate()
    {
        DescriptionList = new List<Candidate>();
        //AllAds = new List<Ads>();
        //VacanciesFilled = new List<Candidate>();
    }


}
公共类候选对象:BaseEntity
{
公共int Id{get;set;}
公共字符串名称{get;set;}
公共整数{get;set;}
公共字符串配置文件文本{get;set;}
公共字节[]CV{get;set;}
公共字符串CVNAME{get;set;}
公共列表配置文件列表{get;set;}
公共字符串标题{get;set;}
公共字符串说明{get;set;}
公共布尔保存{get;set;}
公共字符串状态{get;set;}
公共DateTime DateOfDescription{get;set;}
公共列表描述列表{get;set;}
公共日期时间反馈日期{get;set;}
公共字符串反馈{get;set;}
公共字符串访问器{get;set;}
公共日期时间访谈日期{get;set;}
公共字符串行为{get;set;}
公共列表allad{get;set;}
公共字符串SelectedAd{get;set;}
公共整数{get;set;}
公共列表空间已填充{get;set;}
公共int GivenUp{get;set;}
公共整数{get;set;}
公开候选人()
{
DescriptionList=新列表();
 public class Candidate : BaseEntity
{
    public int Id { get; set; }
    public string Name { get; set; }
    public int Number { get; set; }
    public string ProfileText { get; set; }
    public Byte[] CV { get; set; }
    public string CVNAME { get; set; }
    public List<Profile> ProfileList { get; set; }
    public string Title { get; set; }
    public String Description { get; set; }
    public Boolean Saving { get; set; }
    public string State { get; set; }
    public DateTime DateOfDescription { get; set; }
    public List<Candidate> DescriptionList { get; set; }
    public DateTime FeedbackDate { get; set; }
    public string Feedback { get; set; }
    public String Interviewer { get; set; }
    public DateTime InterViewDate { get; set; }
    public string Behavior { get; set; }
    public List<Ads> AllAds { get; set; }
    public string SelectedAd { get; set; }
    public int Vacancies { get; set; }
    public List<Candidate> VacanciesFilled { get; set; }
    public int GivenUp { get; set; }
    public int Age { get; set; }
    public Candidate()
    {
        DescriptionList = new List<Candidate>();
        //AllAds = new List<Ads>();
        //VacanciesFilled = new List<Candidate>();
    }


}
candidates.DescriptionList.Add(candidates);
applicationContext.Candidates.Add(candidates);