Blog
Type datetime2 is not a defined system type – Entity Framework
Registro rápido de uma simples ocorrência, a título de KB.
Primeiro, a pessoa que não imprime os dados da exceção em si, encontra o erro genérico (pior que o servidor está em português, para ajudar…):
Erro ao executar a definição do comando. Consulte a exceção interna para obter mais detalhes.
STACKTRACE: em System.Data.EntityClient.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior) em System.Data.Objects.Internal.ObjectQueryExecutionPlan.Execute[TResultType](ObjectContext context, ObjectParameterCollection parameterValues) em System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption) em System.Data.Objects.ObjectQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator() em System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) em System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
Em seguida, após recomendação, a pessoa imprime o InnerException para obter maiores detalhes sobre a exceção e obtém:
InnerException System.Data.SqlClient.SqlException: Type datetime2 is not a defined system type. em System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) em System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) em System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) em System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) em System.Data.SqlClient.SqlDataReader.ConsumeMetaData() em System.Data.SqlClient.SqlDataReader.get_MetaData() em System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) em System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) em System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) em System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) em System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) em System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) em System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior) em System.Data.EntityClient.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)
Primeira linha do InnerException: Type datetime2 is not a defined system type.
Solução:
O desenvolvimento foi realizado conectando-se em uma base SQL Server 2008 e no cliente utilizada a versão 2005, então a correção precisa ser feita no modelo (xml):
<edmx:StorageModels> <Schema Namespace="TcwsModel.Store" Alias="Self" Provider="System.Data.SqlClient" ProviderManifestToken="2005" .....>
A alteração está no atributo ProviderManifestToken, que deverá ser alterado de acordo com a versão do banco.
-
27/05/2013
NFS-e Juiz de Fora-MG: Obrigatoriedade de emissão da Nota Fiscal de Serviço Eletrônica
- 17/10/2012
- 09/10/2012
-
12/09/2012
Dynamics CRM 2011 – JavaScript Snippet – Nome dos atributos no lugar dos labels