2017-09-15 108 views
0

底部錯誤細節無編碼和其他提及的實體是我的項目的一部分。我仍然有這個錯誤。當我幾個小時沒有變化開始項目時突然產生這個錯誤。 當第一個基於實體框架的調用發生時,會發生此錯誤。實體框架爲不存在的實體生成錯誤

One or more validation errors were detected during model generation: 

Website1.Models.Encoding: : EntityType 'Encoding' has no key defined. Define the key for this EntityType. 
ActionResults: : The referenced EntitySet 'ActionResults' for End 'ContentResult_ContentEncoding_Source' could not be found in the containing EntityContainer. 
ActionResults: : The referenced EntitySet 'ActionResults' for End 'JsonResult_ContentEncoding_Source' could not be found in the containing EntityContainer. 
Encodings: EntityType: EntitySet 'Encodings' is based on type 'Encoding' that has no keys defined. 
ActionResults: EntityType: EntitySet 'ActionResults' is based on type 'ActionResult' that has no keys defined. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Data.Entity.ModelConfiguration.ModelValidationException: One or more validation errors were detected during model generation: 

Website1.Models.Encoding: : EntityType 'Encoding' has no key defined. Define the key for this EntityType. 
ActionResults: : The referenced EntitySet 'ActionResults' for End 'ContentResult_ContentEncoding_Source' could not be found in the containing EntityContainer. 
ActionResults: : The referenced EntitySet 'ActionResults' for End 'JsonResult_ContentEncoding_Source' could not be found in the containing EntityContainer. 
Encodings: EntityType: EntitySet 'Encodings' is based on type 'Encoding' that has no keys defined. 
ActionResults: EntityType: EntitySet 'ActionResults' is based on type 'ActionResult' that has no keys defined. 

下面是完整的:數據庫類:>HERE

+0

看來你忘了把'KeyAttribute'所需的表列ID。檢查它們是否在數據模型中正確插入。 –

+0

我交叉檢查兩次,每個實體都有關鍵屬性。以下不是我的實體 –

+0

你能否提供相關模型類拋出錯誤?而你通過使用相應的模型類嘗試了什麼? –

回答

0

問題是與不支持表的列之一的數據類型。一列本身代表實體,我不知道如何。

錯誤我定義的數據類型如下:

public ActionResult effectcolumn {get; set;}