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)
*This post is locked for comments
Hi Aiden
Thanks for your response. Yes, I believe you're right. Your suggestion was how I solved the problem.
Thanks
James
Hi James,
Is it possible the primary name field you were setting was "Fact Find Id", a text field? That would explain the issue, since the primary key would always be prefix_entityId and would be duplicated. I bet if you tried to set the primary name field to just "Fact Find" or "Fact Find Name", it would've been fine.
Thanks,
Aiden
Ahh my bad... my problem is actually different... I replied to the wrong thread... sorry about that..
My problem is explained here - https://community.dynamics.com/crm/f/117/t/170749
It's some kind of odd timeout error.
I didn't get any responses but I did figure it out myself in the end.
Basically, under the Primary Key tab don't change the name of the Name field (i.e. leave it as prefix_name).
Hope this works for you. Interested to hear if it works.
James
Did you ever get a fix for this? I am experiencing the exact same issue.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156