Home

Linq Query: InvalidOperationException: The relationship ... because it is not compatible. Configure

I have a database. This database schema is in use for various apps among others .net core apps with EF core

I had a problem with a Linq Query so I thought I'd try to play with this in Linqpad, however:

  • I make a new entity framework core connection in LinqPad
  • Release 5.0.7
  • Connect

Then ... any query complains about an invalid FK

  • I have a table which has a PK of (int, string, int)
  • another table references this with FK int, string, nullable(int) .

I think it complains about the nullable FK key and that this is an incompatible foreign key. So I assume that when you run "any query" it does some validation on the schema overall to start with.

How do I solve this? (it is impossible to change the schema of the database)

Comments

  • edited September 13

    I looked further into this . It seems that it is complaining about 1 specific table which has about 25 Foreign key relations. EF core generator / sql server seem to complain not about anything.

    So there must be somewhere a problem with that specific table. But no clue.

    CONSTRAINT [PK_SysCalculation] PRIMARY KEY CLUSTERED
    (
    [CustomerId] ASC,
    [CalculationTypeId] ASC,
    [Id] ASC
    )

    which is int, int, nvarchar(10)

    A foreign key example is

    FOREIGN KEY([CustomerId], [CalculationTypeId], [CalculationId]) REFERENCES [SysCalculation]
    ([CustomerId], [CalculationTypeId], [Id])

    which is exactly this int, int, nvarchar(10) >> int, int, nvarchar(10)

    Hmm

Sign In or Register to comment.