Skip to content
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

SQL Table Function primary key issue #2417

Closed
ghendric opened this issue Jun 27, 2024 · 10 comments
Closed

SQL Table Function primary key issue #2417

ghendric opened this issue Jun 27, 2024 · 10 comments
Labels
question Further information is requested

Comments

@ghendric
Copy link

I encountered an issue in the latest version of EF Core Power Tools v2.6.287 when referencing a SQL table function. Here is the error message I received:

"The entity type 'EntityTypeName' requires a primary key to be defined. If you intended to use a keyless entity type, call 'HasNoKey' in 'OnModelCreating'. For more information on keyless entity types, see https://go.microsoft.com/fwlink/?linkid=2141943."

HasNoKey was being generated and called when executing the code, but the error occurred when trying to execute anything unrelated to the SQL function. It appears to be connected to how the code was generated by EF Core Power Tools. I downgraded to v2.6.140, ran the reverse engineer option, and this resolved the issue. The generated code layout differed from that of v2.6.287. I'm not sure if this difference is the cause, but I wanted to report the issue.

I'm using VS 2022 Pro 64-bit, Windows 11 64-bit, and the project solution is .NET 8.

@ErikEJ
Copy link
Owner

ErikEJ commented Jun 27, 2024

Which EF Core version exactly do you use at runtime?

@ghendric
Copy link
Author

Which EF Core version exactly do you use at runtime?

Version 8.0.0

@ErikEJ
Copy link
Owner

ErikEJ commented Jun 27, 2024

Have you tried 8.0.6??

@ghendric
Copy link
Author

Have you tried 8.0.6??

No. I can't do that without affecting the solution and causing problems without first making sure the update doesn't break anything for anyone else working on the code. The solution is over a 1.5 million lines of code.

@ErikEJ
Copy link
Owner

ErikEJ commented Jun 27, 2024

8.0.6 is just a minor bug fix update from 8.0.0 - surely you can test your issue against that version locally??

I believe you are facing a bug that has been fixed in 8.0.6

@ErikEJ
Copy link
Owner

ErikEJ commented Jun 28, 2024

dotnet/efcore#32680

@ghendric
Copy link
Author

So is your suggestion to upgrade to EF Core 8.0.6?

@ErikEJ
Copy link
Owner

ErikEJ commented Jun 28, 2024

@ghendric Yes! As I understand, you are running EF Core version 8.0.0 which has a bug, that you are hitting. Updating to 8.0.2 or later will fix that bug - update locally and run a test to verify that it works.

@ghendric
Copy link
Author

ok got it.. thanks!

@ErikEJ ErikEJ closed this as not planned Won't fix, can't repro, duplicate, stale Jun 28, 2024
@ErikEJ
Copy link
Owner

ErikEJ commented Jun 28, 2024

If you like my free tools, I would be very grateful for a rating or review on Visual Studio Marketplace or even a one-time or monthly sponsorship

@ErikEJ ErikEJ added the question Further information is requested label Jun 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants