8
我正在嘗試基於傳統SQL Server 2008數據庫創建實體框架4模型。由於該模型將在Web服務中發佈,因此我需要省略一個稱爲NewsletterSubscribed的模型實體的整數列。實體框架:雖然它具有默認值,但必須映射列?
在EF設計去除柱之後,我得到了下面的編譯錯誤:
Error 59 Error 3023: Problem in mapping fragments starting at line 356:Column Users.NewsletterSubscribed in table Users must be mapped: It has no default value and is not nullable.
C:\Users\Adrian\Documents\Sites\Zeiterfassung\Zeiterfassung\API\V1\EFModel.edmx 357 15 Zeiterfassung
但列似乎已經綁定到它的默認值0。我試圖對數據庫運行該SQL語句:
ALTER TABLE [dbo].[Users] ADD DEFAULT ((0)) FOR [NewsletterSubscribed]
但也失敗:
Msg 1781, Level 16, State 1, Line 3 Column already has a DEFAULT bound to it. Msg 1750, Level 16, State 0, Line 3 Could not create constraint. See previous errors.
因此,無論該列沒有默認值(在這種情況下,我不知道爲什麼我能沒有創建一個),或實體框架沒有看到它。到底是怎麼回事?
感謝,
阿德里安
謝謝!我一直在爲此奮鬥數星期...... – 2011-05-26 04:08:31