2

我已经从这里下载了示例 mvc 应用程序http://ravenmvc.codeplex.com/releases/view/45994

它工作得很好。但我有一个问题。在示例应用程序中 DocumentId 看起来像“categories-2”,但在我调用 Store 方法之后的应用程序中:

        using (var session = DocumentStore.OpenSession())
        {
            session.Store(item);
            session.SaveChanges();
            return item;
        }

我有 DocumentId,例如“projects/3073”。我希望 DocumentId 的格式与示例应用程序一样。我怎么能这样做?有什么我应该改变的选择吗?

4

1 回答 1

4

您需要在初始化 DocumentStore 时设置 DocumentConvention:

var ds = new DocumentStore();
ds.ConnectionStringName = connectionStringName;
ds.Initialize();
ds.Conventions.IdentityPartsSeparator = "-";
于 2010-12-12T13:18:22.187 回答