我剛剛開始在WebMatrix上工作,我做了this教程,學習了基本知識,然後我開始使用this一個開始使用WebMatrix上的Entity Framework(注意:該教程是針對WebMatrix 1,但我看到的唯一改變就是你將helper安裝到你的項目中的方式)。問題是,我安裝了Entity Framework助手,但我的項目無法識別EntityFramework.dll。WebMatrix 2不識別EntityFramework幫手
我得到這個錯誤The type or namespace name 'MaxLength' could not be found (are you missing a using directive or an assembly reference?)
。但EntityFramework.dll確實出現在我的bin文件夾中,發生了什麼?我不明白爲什麼參考不起作用。
這是根據第二個教程和安裝的EntityFramework助手後,我的Web.config文件:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
</configSections>
<system.web>
<compilation debug="true" targetFramework="4.0"><assemblies><add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /><add assembly="System.ComponentModel.DataAnnotations, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /></assemblies></compilation>
</system.web>
<connectionStrings>
<add name="BookContext" connectionString="Data Source=|DataDirectory|Books.sdf" providerName="System.Data.SqlServerCe.4.0" />
</connectionStrings>
</configuration>
這是編譯器輸出link
我缺少的東西?爲什麼EntityFramework.dll不能被我的項目正確識別?
UPDATE
我想,當我從在Visual Studio 2012中創建一個網頁項目複製EntityFramework.dll問題解決了,但即使錯誤不再顯示,WebMatrix中仍然不承認喜歡錶,列,ForeignKey的,InverseProperty等
我真的不明白,創建一個簡單的數據庫,但我不能使用的EntityFramework批註指定所有我需要的數據庫註釋。 WebMatrix應該識別EntityFramewor.dll,但它不是。我需要幫助,因爲我真的迷失了。
MaxLengthAttribute存在於System.ComponentModel.DataAnnotations.dll程序集中。 http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.maxlengthattribute.length.aspx – Pawel
實體框架還具有MaxLengthAttribute http://msdn.microsoft.com/en-us/庫/ system.componentmodel.dataannotations.maxlengthattribute%28v = vs.103%29.aspx –
是的,它曾經住在EntityFramework中,但後來被移動到System.ComponentModel.DataAnnotations – Pawel