I am currently using Entity Framework 5 I've tried to code the following:
var result = context.Database.SqlQuery<Entity>("SELECT * FROM ref.Entity");
But I get the following error:
Specified method is not supported.
Can anyone show me a resolution to this issue?
stack trace
"at EFProviderWrapperToolkit.DbConnectionWrapper.CreateDbCommand()\r\n at System.Data.Common.DbConnection.CreateCommand()\r\n at System.Data.Objects.ObjectContext.CreateStoreCommand(String commandText, Object[] parameters)\r\n at System.Data.Objects.ObjectContext.ExecuteStoreQueryInternal[TElement](String commandText, String entitySetName, MergeOption mergeOption, Object[] parameters)\r\n at System.Data.Objects.ObjectContext.ExecuteStoreQuery[TElement](String commandText, Object[] parameters)\r\n at System.Data.Entity.Internal.InternalContext.ExecuteSqlQuery[TElement](String sql, Object[] parameters)\r\n at System.Data.Entity.Internal.InternalContext.ExecuteSqlQueryAsIEnumerable[TElement](String sql, Object[] parameters)\r\n at System.Data.Entity.Internal.InternalContext.ExecuteSqlQuery(Type elementType, String sql, Object[] parameters)\r\n at System.Data.Entity.Internal.InternalSqlNonSetQuery.GetEnumerator()\r\n at System.Data.Entity.Internal.InternalSqlQuery
1.GetEnumerator()\r\n at System.Linq.SystemCore_EnumerableDebugView
1.get_Items()"
This is mentioned in "Known Problems" section on codeplex "Community Entity Framework Provider Wrappers" site. Citing:
The answer is quite simple. I am not sure if you have the source code of EFProviderWrapperToolkit, you should get it and have a look at it. You will notice that DbConnectionWrapper, which inherits from DbConnection it overrides CreateDbCommand method but does not provide any functionality for it, instead it throws and exception.