當類之一映射到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「, –
顯而易見的問題是,事實上是否在數據庫中。我建議遵循教程。 –