GUID of 00000000-0000-0000-0000-000000000000 causing merge index violation

橙三吉。 提交于 2019-12-05 21:16:42

Did you use "new Guid()" somewhere in your code base when what you meant was "Guid.NewGuid()"?

I had faced the similar problem. As Mark has mentioned in the comment, the Guid() needs to be properly used.

Guid asm = new Guid(); // gives 00000000-0000-0000-0000-000000000000

Instead use

Guid asm = Guid.NewGuid();

When using Linq-To-SQL, make sure the IsDbGenerated property is true and the Database actually is setup to create an ID (by using newid() as the default value).

Otherwise, make sure the .net code is actually generating IDs.

What we discovered while researching your suggestions was that this particular table was the only table that included the guid field at all in the DBML class. All the other tables had been added to the DBML prior to publishing the database for merge replication (hence their respective guid fields were not included in the DBML).

So, I manually deleted the guid field from the problem table in the DBML and the problem went away. The problem was in fact caused by LINQ not creating the guid as it should in the generated classes.

In this case it was easiest to simply leave guid creation to the publication triggers and newid() default value as established in SQL. (it's still in the database, just not the dbml)

Nothing in the application uses those guid fields... it's purely for SQL to manage the merge replication scheme we've implemented - so removing from the DBML was the easiest.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!