A baffling error... When adding a custom entity, I get a SQL error pop up, and this contained in the log file:
Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=7.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: System.Data.SqlClient.SqlException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #42040FB6Detail:
<OrganizationServiceFault xmlns:i="www.w3.org/.../XMLSchema-instance" xmlns="schemas.microsoft.com/.../Contracts">
<ErrorCode>-2147220970</ErrorCode>
<ErrorDetails xmlns:d2p1="schemas.datacontract.org/.../System.Collections.Generic" />
<Message>System.Data.SqlClient.SqlException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #42040FB6</Message>
<Timestamp>2015-07-23T15:47:19.3617506Z</Timestamp>
<InnerFault i:nil="true" />
<TraceText i:nil="true" />
</OrganizationServiceFault>
Our MS Dynamics CRM 2015 is hosted on a server, which I don't have full access to. However, the administrator of the server sent me this from the log, which gives more detail (see below). Note the bits highlighted in red. It seems clear to me that the SQL error is happening because when creating the entity table, Dynamics has created a SQL script that includes the same field name twice: once as uniqueidentifier and once as nvarchar.
I'm really baffled as to why this has happened. I was able to add entities yesterday. This error has just occurred and, as far as I know, with no changes to the server setup since yesterday.
Has anybody seen this before?
With thanks
James
[2015-07-23 13:49:25.532] Process: w3wp |Organization:8c07a7e5-8a21-e511-80bc-0050568c61d1 |Thread: 30 |Category: Platform.Metadata |User: 00000000-0000-0000-0000-000000000000 |Level: Error |ReqId: a03e2e2e-5ce9-4920-83c3-bc6edfc70ea1 | SqlHelper.ExecuteNonQuery ilOffset = 0x29
>Exception when executing non-query: CREATE TABLE dbo.[fcp_factfindBase] ([fcp_factfindId] uniqueidentifier NOT NULL ,
[CreatedOn] datetime NULL ,
[CreatedBy] uniqueidentifier NULL ,
[ModifiedOn] datetime NULL ,
[ModifiedBy] uniqueidentifier NULL ,
[CreatedOnBehalfBy] uniqueidentifier NULL ,
[ModifiedOnBehalfBy] uniqueidentifier NULL ,
[OwnerId] uniqueidentifier NOT NULL ,
[OwnerIdType] int NOT NULL CONSTRAINT [DF_fcp_factfindBase_OwnerIdType] DEFAULT (8) ,
[OwningBusinessUnit] uniqueidentifier NULL ,
[statecode] int NOT NULL ,
[statuscode] int NULL ,
[VersionNumber] timestamp NULL ,
[ImportSequenceNumber] int NULL ,
[OverriddenCreatedOn] datetime NULL ,
[TimeZoneRuleVersionNumber] int NULL ,
[UTCConversionTimeZoneCode] int NULL ,
[fcp_factfindid] nvarchar(100) NULL ,
[processid] uniqueidentifier NULL ,
[stageid] uniqueidentifier NULL ,
[traversedpath] nvarchar(1250) NULL ) Exception: System.Data.SqlClient.SqlException (0x80131904): Column names in each table must be unique. Column name 'fcp_factfindid' in table 'fcp_factfindBase' is specified more than once.
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, Boolean& dataReady)
at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async, Int32 timeout, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at Microsoft.Crm.CrmDbConnection.InternalExecuteWithRetry[TResult](Func`1 ExecuteMethod, IDbCommand command)
at Microsoft.Crm.CrmDbConnection.InternalExecuteNonQuery(IDbCommand command, Boolean capturePerfTrace)
at Microsoft.Crm.CrmDbConnection.ExecuteNonQuery(IDbCommand command, Boolean impersonate, Boolean capturePerfTrace)
at Microsoft.Crm.Metadata.SqlHelper.ExecuteNonQuery(ISqlExecutionContext context, IDbCommand sqlCommand)
ClientConnectionId:655e6de1-4651-47d1-b347-c51d6f48365a
Error Number:2705,State:3,Class:16
[2015-07-23 13:49:25.563] Process: w3wp |Organization:8c07a7e5-8a21-e511-80bc-0050568c61d1 |Thread: 30 |Category: Platform.Metadata |User: 00000000-0000-0000-0000-000000000000 |Level: Error |ReqId: a03e2e2e-5ce9-4920-83c3-bc6edfc70ea1 | EntityService.Create ilOffset = 0xB1
>EntityService.Create caught exception: System.Data.SqlClient.SqlException (0x80131904): Column names in each table must be unique. Column name 'fcp_factfindid' in table 'fcp_factfindBase' is specified more than once.
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, Boolean& dataReady)
at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async, Int32 timeout, Boolean asyncWrite)