0

我只是不能得到這個工作!我查看了所有其他相關主題,而且他們都不適合我。這是目前我的連接字符串:EF 5代碼優先與SQL Server Express 2012和Visual Studio 2012

<add name='UniContext' connectionString='Server=.\SQLEXPRESS;Database=ContosoUni;Integrated Security=SSPI;User Instance=true' providerName='System.Data.EntityClient'/> 

我得到的錯誤是:

enter image description here

我將不勝感激任何幫助。

感謝

回答

1

試圖改變供應商的名字從System.Data.EntityClient到System.Data.SqlClient的

+0

謝謝尤蘇波夫,即擺脫了錯誤的,但東西是不正確,不表是正在SQL Server Express上的數據庫中創建!這是一個截圖! [http://goo.gl/znpYT] – Ciwan 2013-02-13 12:43:05

+0

@Ciwan你有初始化策略嗎?看看這裏http://stackoverflow.com/questions/6281447/ef-code-first-not-generating-tables,你也應該映射你的數據庫上下文的類與聲明DbSet或使用流利的接口覆蓋OnModelCreating方法http://stackoverflow.com/questions/4759004/what-the-purpose-of-onmodelcreating-in-ef4-code-first – Yusupov 2013-02-13 16:01:33

+0

謝謝,我做了以下:[Database.SetInitializer(新的DropCreateDatabaseIfModelChanges ()); ]但仍然沒有表正在我的SQL Express數據庫中創建! :( – Ciwan 2013-02-15 10:50:34