Asp.net mvc 2 RavenDB中的DocumentId存在问题
我已经从这里下载了示例mvc应用程序 它很好用。但我有一个问题。在示例应用程序中,DocumentId看起来像“categories-2”,但在我调用Store方法后的应用程序中:Asp.net mvc 2 RavenDB中的DocumentId存在问题,asp.net-mvc-2,ravendb,Asp.net Mvc 2,Ravendb,我已经从这里下载了示例mvc应用程序 它很好用。但我有一个问题。在示例应用程序中,DocumentId看起来像“categories-2”,但在我调用Store方法后的应用程序中: using (var session = DocumentStore.OpenSession()) { session.Store(item); session.SaveChanges(); return item
using (var session = DocumentStore.OpenSession())
{
session.Store(item);
session.SaveChanges();
return item;
}
我有类似“项目/3073”的文档ID。我希望DocumentId的格式与示例应用程序中的格式相同。我怎么能做到?是否有一些选项需要更改?在初始化DocumentStore时,您需要设置DocumentConvention:
var ds = new DocumentStore();
ds.ConnectionStringName = connectionStringName;
ds.Initialize();
ds.Conventions.IdentityPartsSeparator = "-";