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
ForeignKey.AreCompatible requires that the foreign and principal keys' CLR properties correspond exactly. While SQL Server is indeed very strict about that, other database support wider foreign key types pointing to narrower principal keys.
On SQL Server:
CREATETABLEposts (id INTPRIMARY KEY);
CREATETABLEpolls (post_id BIGINTREFERENCES posts(id));
... errors with Column 'posts.id' is not the same data type as referencing column 'polls.post_id' in foreign key 'FK__polls__post_id__5165187F'..
However, the same DDL works fine on PG and Sqlite. We could allow some sort of provider hook that determines whether the properties types are compatible.
Although it is possible to make EF Core support different types for principal and foreign keys, that's likely quite difficult to do. On the other hand, as specified in #19793, it's possible to simply specify the different store type in the model.
@jessicah although this wouldn't unblock the scaffolding scenario, try to simply define your foreign key as an INT in your model (instead of BIGINT) and everything should work.
ForeignKey.AreCompatible requires that the foreign and principal keys' CLR properties correspond exactly. While SQL Server is indeed very strict about that, other database support wider foreign key types pointing to narrower principal keys.
On SQL Server:
... errors with
Column 'posts.id' is not the same data type as referencing column 'polls.post_id' in foreign key 'FK__polls__post_id__5165187F'.
.However, the same DDL works fine on PG and Sqlite. We could allow some sort of provider hook that determines whether the properties types are compatible.
Originally flagged by @jessicah in npgsql/efcore.pg#1515
The text was updated successfully, but these errors were encountered: