Dopo l'aggiornamento a Entity Framework 6 abbiamo implementato la nostra DbExecutionStrategy. Oltre alla già esistente SqlAzureExecutionStrategy, la nostra strategia registra anche le eccezioni. Come si è visto, ogni 15-30 minuti Entity Framework lancia SqlException interna System.Data.SqlClient.SqlException (0x80131904): Invalid column name 'CreatedOn'.
Si tratta di un errore interno. Sembra che EF esegua alcuni controlli regolari se la colonna CreatedOn esiste su qualche tabella. C'è un modo elegante per evitare che questa eccezione venga lanciata?Creato in colonna Entity Framework 6
Ecco uno stack di chiamate:
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, ref Boolean dataReady)
at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData()
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, ref Task task, Boolean asyncWrite, SqlDataReader ds)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, ref Task task, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch(Func`1 operation, TInterceptionContext interceptionContext, Action`1 executing, Action`1 executed)
at System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.Reader(DbCommand command, DbCommandInterceptionContext interceptionContext)
at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)
Anche questo errore si verifica. –
Possibile duplicato di [Entity Framework 4.3. Nome colonna non valido 'CreatedOn'] (http://stackoverflow.com/questions/12193465/entity-framework-4-3-invalid-column-name-createdon) – AXMIM
"_... controlla se la colonna CreatedOn esiste su ** alcuni ** table._ "Puoi utilizzare il SQL Profiler di SQL Server Management Studio per scoprire cosa sta inviando SQL EF al tuo server. Nel mio caso, ho visto 'SELECT TOP (1) [c]. [CreatedOn] AS [CreatedOn] FROM [dbo]. [__ MigrationHistory] AS [c]', che ha chiarito che aveva qualcosa a che fare con un EF versione non corrispondente. –