-
-
Notifications
You must be signed in to change notification settings - Fork 266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Composite primary key errors #835
Comments
Thanks for creating the fork. Just out of curiosity have you tried different database providers at all? I'm trying to figure out the scope of the issue and if it is specific to one provider or something similar. It may be more fundamental than that. Also do you think this is something that could impact a non Finbuckle.MultiTenant db context? Is there a way to arbitrarily reproduce it by setting a primary key as a composite on regular db context? |
So I initially encountered this using the I've never personally created a "virtual" composite key before. I'm also trying to decide how to proceed on my side. i.e is it fine for the PK/FK relationship to just be on the ID field, and just use |
I tried to add tenantId as a key in Postgres and SQLSERVER. The issue exists for both the DBs
|
It’s an issue at the tracker level for any db provider. There is a workaround example from pr #834
|
So, Do I need to add this work around in every controller and each API? |
basically yes, but you can get EFCore to fix/automated this for you, doing something like this In your application context
In your entity
|
"Reopening" this as this does seem to be an issue, or it's a misunderstanding.
Using a standard reference implementation of composite keys, you'll get an error when calling
Add
on an Entity in the DBContext:InvalidOperationException: Unable to track an entity of type 'Client' because its primary key property 'TenantId' is null.
I have created a PR/fork of the sample project that can reproduce this issue: #834
The text was updated successfully, but these errors were encountered: