Unique indexes do not seem to work in combination with document inheritance #1421
-
When using this combination the unique index is not created in the database. However, creating an instance of the DocumentStore does not complain about this inability. I might be missing something though as I am just started using Marten.
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
It does seem to work if I put the UniqueIndex on the class where the property is defined. But only when that class is the base of the inheritance structure, using it on a subclass still wont work. If I move the property to be indexed to a subclass it wont work
|
Beta Was this translation helpful? Give feedback.
-
@sensoryoverload Sorry about the delayed reply. Few things to note when you use document hierarchies/inheritance:
If you did not register document hierarchies i.e. I think we have to update the docs to add some clarity around the limitations of using unique indexes on sub classes in the document hierarchies. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the response. In retrospect, I should have known that what I tried would not work. |
Beta Was this translation helpful? Give feedback.
@sensoryoverload Sorry about the delayed reply. Few things to note when you use document hierarchies/inheritance:
_.Schema.For<JobPosition>().AddSubClass<ExternalJobPosition>();
, this line tells Marten that these classes have document hierarchiesIf you did not register document hierarchies i.e.
_.Sch…