Reputation: 11
I've encountered a very specific problem regarding code-first EF 6.0, and I don't believe what I'm trying to accomplish is supported by EF 6. At a high level, I'd like to create an index on a table over three columns, and I'd like this index to include the Discriminator
column.
Unfortunately, there is not a way to access shadow properties (like the Discriminator
) via FluentAPI in EF6 (this functionality is only present in EF Core).
Does anyone have any experience with manually making changes to the schema outside of the code-first approach, and then bringing the code-first model up to speed with manual SQL Server updates?
Or do you have any suggestions to implement this index that do not involve adding additional columns to my code-first schema?
I've looked into manually creating an index on SQL Server for the three columns, but doing so will throw the code-first model out of sync with the DB model, as no entry in the Migrations
table would be made for the manually created index.
I find it very strange that the code-first framework prohibits me from accessing data that is stored in my database. I understand that the Discriminator
is used behind the scenes by EF when implementing the table per hierarchy schema design, I just find it unnecessarily prohibitive to disallow access to columns within my database.
Any suggestions are welcome!
Upvotes: 1
Views: 43