Open lonix1 opened 3 years ago
See corresponding StackOverflow issue where this problem was correctly diagnosed.
It was explained there that this behavior is surprising because it works differently on different databases, and a more sensible exception should be thrown to alert the developer to the true underlying problem. What are your thoughts?
dotnet/efcore#11162 covers adding a warning for this to the generated migration.
Moving this to docs to better document the issue with relation to owned collections on SQLite.
We can also change the convention to generate a simple PK for this case
File a bug
Include your code
I have a
Comment
owned entity type:And
Post
's configuration includes:The seeding code includes this:
When I use the postgres provider, I can successfully create, seed and edit the database.
When I use the sqlite provider, I can successfully create the database, but when I try to seed it I get an exception. See below.
Include stack traces
Include verbose output
No applicable info.
Include provider and version information
EF Core version: 5.0.11 Database provider: Microsoft.EntityFrameworkCore.Sqlite version 5.0.11 Target framework: .NET 5.0 Operating system: linux IDE: vscode 1.61.0
Extras
The docs say that the owned table has an implicit key, which explains the complaint about
Comment.Id
.But why does this only happen for sqlite, and how do I deal with it?