Skip to content

Unique indexes do not seem to work in combination with document inheritance #1421

Answered by mysticmind
sensoryoverload asked this question in Q&A
Discussion options

You must be logged in to vote

@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 hierarchies
  • All the documents pertaining to the hierarchies gets stored in one table and Marten provides you the ability to query on base class or sub classes. When defining any indexes including unique indexes, it can be applied only on base classes (you have already observed as the behavior).
  • There are few limitations when would want to use the document hierarchies and unique indexes on sub classes.

If you did not register document hierarchies i.e. _.Sch…

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by mysticmind
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1421 on November 28, 2020 07:59.