我試圖拿起ASP.Net - 並按照MVC教程:http://www.asp.net/mvc/tutorials/mvc-music-store-part-4(注:我完全新的.NET框架,C#和ASP.Net)ASP.Net DB播種
在本教程開始使用SQL Server Compact 4.0 - 但是,我安裝了SQL Server Express(因爲我將在後面使用它,而不僅僅是教程)。我有另一個問題,已經解決了關於設置數據庫連接:ASP.Net SQL ConnectionStrings config
現在,顯然數據庫是空的 - 教程甚至沒有說實例化數據庫,除了下載一些資產文件的數據庫「SampeData.cs 」,並把它添加到Global.asax.cs中的Application_Start方法:
System.Data.Entity.Database.SetInitializer(new MvcMusicStore.Models.SampleData());
所以我就DB連接,但現在我得到:
Model compatibility cannot be checked because the database does not contain model metadata. Ensure that IncludeMetadataConvention has been added to the DbModelBuilder conventions.
當我把調試點 - 有時候Application_Start m方法被擊中,有時它沒有。但是,我從來沒有看到過SampleData.cs被擊中種子法 - 所以在我看來,我的問題,現在是播種分貝