You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to create a composite unique constraint using one column from entity property (AssessmentId) and the other from an owned complex type property (User.Code) .
The generated index should look something like this:
CREATEUNIQUE INDEXUserAssessments_AssessmentId_IDX USING BTREE ONDemoDb.UserAssessments (AssessmentId,User_Code);
I have tried different ways to declare the unique index but still migration fails with the following errors:
'User' cannot be used as a property on entity type 'UserAssessment' because it is configured as a navigation.
The property 'Code' cannot be added to the type 'UserAssessment' because there was no property type specified and there is no corresponding CLR property or field. To add a shadow state property the property type must be specified
The properties expression 'x => new <>f__AnonymousType3`2(AssessmentId = x.AssessmentId, Code = x.User.Code)' is not valid. The expression should represent a simple property access: 't => t.MyProperty'. When specifying multiple properties use an anonymous type: 't => new { t.MyProperty1, t.MyProperty2 }'.
Parameter name: propertyAccessExpression
'User' cannot be used as a property on entity type 'UserAssessment' because it is configured as a navigation.
Am I doing something wrong on the declaration of index or this is a missing feature on EF Core and if so is there any way around this issue.
Further technical details
EF Core version: 2.2.6
Database provider: (MySql.Data.EntityFrameworkCore 8.0.18)
Target framework: (.Net.Core 2.2)
Database: MySQL 8+ (InnoDB)
Operating system: Windows 10 PRO
IDE: Visual Studio Enterprise 2019 (16.3.7)
Thanks
The text was updated successfully, but these errors were encountered:
I am trying to create a composite unique constraint using one column from entity property (AssessmentId) and the other from an owned complex type property (User.Code) .
Model Declaration
EF Core Entity Configuration
** Migration Command **
The generated index should look something like this:
I have tried different ways to declare the unique index but still migration fails with the following errors:
Parameter name: propertyAccessExpression
Am I doing something wrong on the declaration of index or this is a missing feature on EF Core and if so is there any way around this issue.
Further technical details
EF Core version: 2.2.6
Database provider: (MySql.Data.EntityFrameworkCore 8.0.18)
Target framework: (.Net.Core 2.2)
Database: MySQL 8+ (InnoDB)
Operating system: Windows 10 PRO
IDE: Visual Studio Enterprise 2019 (16.3.7)
Thanks
The text was updated successfully, but these errors were encountered: