I am using this query:
List<PRODUCT> prods = (from product in dsmEntities.PRODUCTs
where product.ID.Equals(ObjReference.savedProduct.ID)
select product).ToList();
I am getting SQl exception about invalid column which I don't even use in the query:
A first chance exception of type 'System.Data.EntityCommandExecutionException' occurred in System.Data.Entity.dll
InvokeEventHandler(): An error occurred while executing the command definition. See the inner exception for details.,
System.Data.SqlClient.SqlException (0x80131904): Invalid column name 'IdEdition'.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.SqlInternalConnection.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, 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, Boolean isInternal, Boolean forDescribeParameterEncryption)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
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.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.EntityClient.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)
ClientConnectionId:920d96f8-da48-48bd-8649-1f75190742ba
Error Number:207,State:1,Class:16
I am guessing, something else happens too, which I am not able to find, what it is.
Can I somehow follow the path of execution of this query? Or what could the problem be? Or maybe the metadata in EDMX about the tables in SQL is corrupted?
IdEdition is not in PRODUCTs table but it does extst as field in savedProduct. Not sure how the query relates. All seems fine.
EDIT:
Using a code snippet to print the actual query executed on server i got this:
sql: SELECT
[Extent1].[ID] AS [ID],
[Extent1].[Name] AS [Naem],
[Extent1].[IdEdition] AS [IdEdition]
FROM [dbo].[PRODUCT] AS [Extent1]
WHERE [Extent1].[ID] = @p__linq__0
Here is my Product table design
ID varchar(20) Unchecked
Name nvarchar(255) Checked
No IdEdition field. And also it depends on totally different table not related in any way to IdEdition column.
I am also flipping connection strings, test to production and vice versa. Could this be doing something? Or I trully have corrupted EDMX file?
Oh, no I see IdEdition in my EDMX file, Products baloon. What the hell!!!
User contributions licensed under CC BY-SA 3.0