C# 尝试将其他对象与id关联(将对象保存到ravendb时)
我有以下代码,其中我创建了新对象并试图保存到raven数据库中。 我要走了 Raven.Client.Exceptions.UnuniqueObjectException 在RavenSession.Store上(retrievedUrl)代码> 带有以下异常消息C# 尝试将其他对象与id关联(将对象保存到ravendb时),c#,.net,ravendb,C#,.net,Ravendb,我有以下代码,其中我创建了新对象并试图保存到raven数据库中。 我要走了 Raven.Client.Exceptions.UnuniqueObjectException 在RavenSession.Store上(retrievedUrl) 带有以下异常消息 An exception of type 'Raven.Client.Exceptions.NonUniqueObjectException' occurred in Raven.Client.Lightweight.dll but w
An exception of type 'Raven.Client.Exceptions.NonUniqueObjectException'
occurred in Raven.Client.Lightweight.dll but was not handled in user code
Additional information: Attempted to associate a different object
with id 'RetrievedUrl/361'.
似乎您正在尝试保存(至少)两个具有相同Id的不同对象,但这是不可能的。RavenDB在存储新文档时会自动创建唯一的Id,但是,如果您明确定义文档Id,则将使用该Id。有关更多信息,请参见。这意味着会话中已存在具有相同id的不同对象。我的解决方法是使用新会话。或者,您可以根据复制值,其中是
retrievedUrl=newretrievedURL{Id=url.Id,url=url.url}中的url
对象代码>来自哪里?
An exception of type 'Raven.Client.Exceptions.NonUniqueObjectException'
occurred in Raven.Client.Lightweight.dll but was not handled in user code
Additional information: Attempted to associate a different object
with id 'RetrievedUrl/361'.