当类之一映射到db中的表时,是否可以创建类继承?我试图使用这个类为不同的方法,我想只显示我需要的信息将类继承映射到表c时#
我收到此错误“消息”:“错误。”,“ExceptionMessage”:“列名称”Discriminator “无效 ” “ExceptionType。”: “System.Data.SqlClient.SqlException”
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Someproject.Models
{
[Table("Vo_User")]
public class FirstClass
{
[Key]
public Int64 id { get; set; }
public string title { get; set; }
public string post { get; set; }
}
public class SecondClass : FirstClass
{
public string State { get; set; }
public Int32? Code { get; set; }
public Int32? Company { get; set; }
public string Flag_Approved { get; set; }
[ForeignKey("IdExample")]
public virtual ICollection<ExampleClass> Example { get; set; }
}
}
“消息”: “错误”, “ExceptionMessage”:“ 厄尔尼诺农布雷迪奥斯columna '鉴别' 无“, ”ExceptionType“:”System.Data.SqlClient.SqlException“
问题到底是什么? – logix
@logix问题是,当我尝试获取数据时出现错误...这是来自web api项目的一部分.... “InnerException”:{ “Message”:“Error “, ”ExceptionMessage“:”列名'Discriminator'无效。“, ”ExceptionType“:”System.Data.SqlClient.SqlException“, –
显而易见的问题是,事实上是否在数据库中。我建议遵循教程。 –