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

Impove unsupported type exception #26341

Closed
paviano opened this issue Oct 14, 2021 · 3 comments · Fixed by #26398
Closed

Impove unsupported type exception #26341

paviano opened this issue Oct 14, 2021 · 3 comments · Fixed by #26398
Labels
area-type-mapping closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported type-enhancement
Milestone

Comments

@paviano
Copy link

paviano commented Oct 14, 2021

Hi guys,
it appears that SQLite support object type property with 'HasColumnType("text")' but the same not works on Microsoft SQL Server and Posgres neither. The property is a standard autoproperty

The property 'DataItemExtended.Value' is of type 'object' which is not supported by the current database provider. Either change the property CLR type, or ignore the property using the '[NotMapped]' attribute or by using 'EntityTypeBuilder.Ignore' in 'OnModelCreating'.

@roji
Copy link
Member

roji commented Oct 14, 2021

@paviano which types a database support - and which .NET types can be mapped to it - is a provider-specific question; what works in SQLite won't necessarily work in SQL Server or PostgreSQL, and vice versa. SQLite and PostgreSQL indeed have a text type, but SQL Server does not (nvarchar(x) or varchar(x) are used instead). Apart from that, most providers don't support mapping .NET properties of type object - you need to use a more specific type, e.g. string in this case.

@paviano
Copy link
Author

paviano commented Oct 14, 2021

🙌 😭 i wanna die

*Quick question

isn't incorrect not to evidenciate the fact that the type "text" is not supported by the provider? (eg. "text" with SQL Server)

@ajcvickers
Copy link
Contributor

Note for triage: It would be useful to include the store type in the exception message here.

@ajcvickers ajcvickers self-assigned this Oct 16, 2021
@ajcvickers ajcvickers added this to the MQ milestone Oct 16, 2021
ajcvickers added a commit that referenced this issue Oct 18, 2021
Fixes #19383
Fixes #17123

> No suitable constructor was found for entity type 'BlogNone'. The following constructors had parameters that could not be bound to properties of the entity type: cannot bind 'did' in 'BlogNone(string title, int did)'; cannot bind 'notTitle' in 'BlogNone(string notTitle, Guid? shadow, int id)'; cannot bind 'dummy' in 'BlogNone(string title, Guid? shadow, bool dummy, int id)'; cannot bind 'dummy', 'description' in 'BlogNone(string title, Guid? shadow, bool dummy, int id, string description)'. Note that only mapped properties can be bound to constructor parameters. Navigations to related entities, including references to owned types, cannot be bound.

Fixes #26341

> The 'DateOnly' property 'Blog.PostedOn' could not be mapped because the database provider does not support this type. Consider converting the property value to a type supported by the database using a value converter. See https://aka.ms/efcore-docs-value-converters for more information. Alternately, exclude the property from the model using the '[NotMapped]' attribute or by using 'EntityTypeBuilder.Ignore' in 'OnModelCreating'.

Or if the store type is specified:

> The 'DateOnly' property 'Blog.PostedOn' could not be mapped to the database type 'datetime2' because the database provider does not support mapping 'DateOnly' properties to 'datetime2' columns. Consider mapping to a different database type or converting the property value to a type supported by the database using a value converter. See https://aka.ms/efcore-docs-value-converters for more information. Alternately, exclude the property from the model using the '[NotMapped]' attribute or by using 'EntityTypeBuilder.Ignore' in 'OnModelCreating'.

Fixes #21954

> Cannot save instance of 'Skinner' because it is an owned entity without any reference to its owner. Owned entities can only be saved as part of an aggregate also including the owner entity.
@ajcvickers ajcvickers changed the title 'object' type with column type 'Text' works on SQLite but not in SQLServer Impove unsupported type exception Oct 18, 2021
@ajcvickers ajcvickers modified the milestones: MQ, 7.0.0 Oct 18, 2021
@ajcvickers ajcvickers added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Oct 18, 2021
ajcvickers added a commit that referenced this issue Oct 19, 2021
Fixes #19383
Fixes #17123

> No suitable constructor was found for entity type 'BlogNone'. The following constructors had parameters that could not be bound to properties of the entity type: cannot bind 'did' in 'BlogNone(string title, int did)'; cannot bind 'notTitle' in 'BlogNone(string notTitle, Guid? shadow, int id)'; cannot bind 'dummy' in 'BlogNone(string title, Guid? shadow, bool dummy, int id)'; cannot bind 'dummy', 'description' in 'BlogNone(string title, Guid? shadow, bool dummy, int id, string description)'. Note that only mapped properties can be bound to constructor parameters. Navigations to related entities, including references to owned types, cannot be bound.

Fixes #26341

> The 'DateOnly' property 'Blog.PostedOn' could not be mapped because the database provider does not support this type. Consider converting the property value to a type supported by the database using a value converter. See https://aka.ms/efcore-docs-value-converters for more information. Alternately, exclude the property from the model using the '[NotMapped]' attribute or by using 'EntityTypeBuilder.Ignore' in 'OnModelCreating'.

Or if the store type is specified:

> The 'DateOnly' property 'Blog.PostedOn' could not be mapped to the database type 'datetime2' because the database provider does not support mapping 'DateOnly' properties to 'datetime2' columns. Consider mapping to a different database type or converting the property value to a type supported by the database using a value converter. See https://aka.ms/efcore-docs-value-converters for more information. Alternately, exclude the property from the model using the '[NotMapped]' attribute or by using 'EntityTypeBuilder.Ignore' in 'OnModelCreating'.

Fixes #21954

> Cannot save instance of 'Skinner' because it is an owned entity without any reference to its owner. Owned entities can only be saved as part of an aggregate also including the owner entity.
@ajcvickers ajcvickers modified the milestones: 7.0.0, 7.0.0-preview1 Feb 14, 2022
@ajcvickers ajcvickers modified the milestones: 7.0.0-preview1, 7.0.0 Nov 5, 2022
@ajcvickers ajcvickers removed their assignment Sep 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-type-mapping closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported type-enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants