Skip to content

Exception message for type mismatches #35846

Open
@ankane

Description

@ankane

What problem are you trying to solve?

Hi, when specifying a CLR type that does not match the SQL type, like:

public class Item
{
    [Column(TypeName = "int")]
    public string? Count { get; set; }
}

EF Core throws a System.InvalidOperationException with the message:

The property 'Item.Count' could not be mapped because it is of type 'string', which is not a supported primitive type or a valid entity type. Either explicitly map this property, or ignore it using the '[NotMapped]' attribute or by using 'EntityTypeBuilder.Ignore' in 'OnModelCreating'.

However, string is a supported type, so this message seems a bit confusing (this applies to all types, string is just an example).

Describe the solution you'd like

An error message that mentions a type mismatch.

Metadata

Metadata

Assignees

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions