2

ユースケースはこちら

  • SQLExpress で、列 ID と名前を持つテーブル Posts を作成しました
  • edmxはそのテーブルに基づいて作成されます
  • 同じ構造 (テーブル名 Posts、列 ID および Name) で SQLCompact データベースを作成します。

SqlCompact DB を指すように app.config を更新すると (正しい方法で行うと仮定して)、EF コードは SqlCompact db でシームレスに動作しますか?

これを尋ねている理由は、上記を試したときに発生する例外に関連しています

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)
4

1 に答える 1

2

単一のedmxは、SQLServerとSQLCompactMSDN フォーラムの両方に使用できないようです。

これがedmxのポイントをどれだけ上回るかはわかりませんが、それが私の質問に対する答えです:)

于 2010-07-05T08:20:05.417 に答える