2
SQLCompact,而SQLEXPRESS儲藏間這裏的用例交換在實體框架4
- 在的SQLExpress我創建
- EDMX是基於表
- 我創建了列ID和名稱表的帖子創建具有相同結構SQLCompact數據庫(表名的帖子,列編號和名稱)
如果我更新的app.config指向SqlCompact數據庫(假設我以正確的方式做到這一點),EF代碼將與SqlCompact數據庫無縫工作?
爲什麼我問這是關係到異常以上
System.InvalidCastException occurred
Message=Unable to cast object of type 'System.Data.SqlServerCe.SqlCeConnection' to type 'System.Data.SqlClient.SqlConnection'.
Source=System.Data
StackTrace:
at System.Data.SqlClient.SqlCommand.set_DbConnection(DbConnection value)
at System.Data.Common.DbCommand.set_Connection(DbConnection value)
at System.Data.Common.Utils.CommandHelper.SetStoreProviderCommandState(EntityCommand entityCommand, EntityTransaction entityTransaction, DbCommand storeProviderCommand)
at System.Data.EntityClient.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)
at System.Data.Objects.Internal.ObjectQueryExecutionPlan.Execute[TResultType](ObjectContext context, ObjectParameterCollection parameterValues)
at System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
at System.Data.Objects.ObjectQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator()
at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
at System.Data.Objects.ELinq.ObjectQueryProvider.<GetElementFunction>b__1[TResult](IEnumerable`1 sequence)
at System.Data.Objects.ELinq.ObjectQueryProvider.ExecuteSingle[TResult](IEnumerable`1 query, Expression queryRoot)
at System.Data.Objects.ELinq.ObjectQueryProvider.System.Linq.IQueryProvider.Execute[S](Expression expression)
at System.Linq.Queryable.FirstOrDefault[TSource](IQueryable`1 source)
非常討厭。 – 2012-07-19 13:59:20