EfCore.SchemaCompare icon indicating copy to clipboard operation
EfCore.SchemaCompare copied to clipboard

Index reported as Extra in Database, but it is also in the model.

Open urielzen opened this issue 1 year ago • 2 comments

Hi, I am using SQL Server, and I am getting the following errors.

EXTRA IN DATABASE: Index 'AuthorityStandards', index constraint name. Found = IX_AuthorityStandards_ExtId
EXTRA IN DATABASE: Index 'AuthorityStandards', index constraint name. Found = IX_AuthorityStandards_GradeLevelId
EXTRA IN DATABASE: Index 'AuthorityStandards', index constraint name. Found = IX_AuthorityStandards_SubjectId
EXTRA IN DATABASE: Index 'AuthorityStandards', index constraint name. Found = IX_AuthorityStandards_AuthorityId_SubjectId_GradeLevelId_Name_YearAdopted

My entity class is decorated accordingly

image

The GradeLevelId and SubjectId are there because they are FK to another table.

image

As I was writing this bug report I thought that maybe this had to do with another bug report I created earlier. Errors when using JSON columns

Since the error in both bug reports happen to be in tables where both have a JSON column. So I went ahead and removed the JSON column with a migration from this table AuthorityStandards and the error reported above went away! In other words these errors are reported only when there is a JSON column present in the table.

I hope this helps

urielzen avatar Nov 27 '23 01:11 urielzen

I have a similar issue when I use a value object. The error message I get is:

EXTRA IN DATABASE: Index 'Order', index constraint name. Found = IX_Order_CustomerId

I have simplified my project and recreated this issue here. I subsequently created another branch which removed the ShippingAddress field off of the Order entity here. The unit test that does the comparison succeeds when I remove the ShippingAddress field

By the way, here is some information on my system

I am using:

  • EfCore.SchemaCompare 8.0.1

  • Visual Studio 2022 Version 17.8.7

  • SQL Server 15 (the tests write to the (localdb)\mssqllocaldb)

  • EF Core 8

CSharpFiasco avatar Feb 23 '24 17:02 CSharpFiasco