-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Support Identity Column Creation on Value Mapped Key Columns #12135
Comments
Update. Modifying migrations manually configures the table correctly:
Now I still can't insert a new record without getting this:
I've tried adjusting the value mapping to pass a null and/or setting the CustomerKey property to null, etc. but so far can't convince EF not to pass that column into the INSERT statement. What's the trick to let it know that (I'm guessing it's marking it as an IDENTITY column which is the root problem of this issue)? |
According to the docs for
but now I get this
I don't want to specify explicit values - I want them generated on add. My value is the default (null). Just perform the insert without that column and set the value to the value in the column. Why isn't this supported? Thanks. Still trying to get this scenario to work one way or another. |
Thanks. Do you think your workaround from here: #11970 (comment) would work in this case (difference being a class, not an enum, as key type)? |
@ardalis I suspect not (I didn't expect it to work for enums) but if you try it and it works, or you find a different workaround, then please let us know. |
I'm trying to use a value mapped key column which has a POCO class on the C# side but maps to/from a simple int column on the SQL side. I'd like EF Migrations to support this and let me set this column up as an Identity column. Here's the configuration for the class:
If you are seeing an exception, include the full exceptions details (message and stack trace).
Steps to reproduce
Here's my Entity and its Key class:
Further technical details
EF Core version:
Database Provider: Microsoft.EntityFrameworkCore.SqlServer
Operating system: Win10
IDE: 15.7.1
The text was updated successfully, but these errors were encountered: