问题
I am trying to port an existing application from EF 6 and MySQL.Data.Entity.EF6 to EF Core and Pomelo.EntityFrameworkCore.MySql.
When the DBContext creates its model, it throws an ArgumentException with message "Unqualified data type char."
I can reproduce the error in a brand-new Console project. As soon as I add a DBSet<Site> to my DBContext, where Site is a class from my existing project's Database.Entities dll, the validation error appears.
Abbreviated stack trace:
at Pomelo.EntityFrameworkCore.MySql.Storage.Internal.MySqlTypeMappingSource.ValidateMapping(CoreTypeMapping mapping, IProperty property)
at Microsoft.EntityFrameworkCore.Storage.RelationalTypeMappingSource.FindMappingWithConversion(RelationalTypeMappingInfo& mappingInfo, IReadOnlyList`1 principals)
...
at Microsoft.EntityFrameworkCore.Infrastructure.ModelSource.GetModel(DbContext context, IConventionSetBuilder conventionSetBuilder, IModelValidator validator)
at Microsoft.EntityFrameworkCore.Internal.DbContextServices.CreateModel()
...
at Microsoft.EntityFrameworkCore.DbContext.get_Model()
The existing class is pretty simple. It looks like this (actually, the Id is inherited from a base class):
public class Site {
[DatabaseGenerated(DatabaseGeneratedOption.None)]
[Required]
public string Id { get; set; }
[Required]
public string Name { get; set; }
[ForeignKey("ApplicationId")]
public virtual Application Application { get; set; }
[Column("ApplicationId")]
[Required]
public string ApplicationId { get; set; }
}
Is there something about the way the existing Dll is compiled that affects this? Can I override something in OnModelCreating to avoid this error? Is there any way to get further insight into what property is being seen as "char"?
来源:https://stackoverflow.com/questions/57662470/pomelo-entityframeworkcore-mysql-dbcontext-throwing-unqualified-data-type-char