MySQLNumberTypeMapping'不支持值转换 [英] MySQLNumberTypeMapping' does not support value conversions

查看:190
本文介绍了MySQLNumberTypeMapping'不支持值转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我添加了一些用于连接到SQL数据库的模型,现在正移植到MySQL.运行时出现此错误:dotnet ef update --context {context}

I've added a few models that I used to connect to a SQL database with and are now porting to MySQL . I am getting this error when I run : dotnet ef update --context {context}

Blockquote System.NotImplementedException:"MySQLNumberTypeMapping"不支持值转换.支持值转换通常需要更改数据库提供程序. 在Microsoft.EntityFrameworkCore.Storage.RelationalTypeMapping.Clone(ValueConverter转换器) 在Microsoft.EntityFrameworkCore.Storage.RelationalTypeMappingSource.b__7_0(ValueTuple 3 k) at System.Collections.Concurrent.ConcurrentDictionary 2.GetOrAdd(TKey键,Func 2 valueFactory) at Microsoft.EntityFrameworkCore.Storage.RelationalTypeMappingSource.FindMappingWithConversion(RelationalTypeMappingInfo& mappingInfo, IReadOnlyList 1主体)) 在Microsoft.EntityFrameworkCore.Storage.RelationalTypeMappingSource.FindMapping(MemberInfo成员) 在Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.PropertyDiscoveryConvention.IsCandidatePrimitiveProperty(PropertyInfo propertyInfo) 在Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.PropertyDiscoveryConvention.Apply(InternalEntityTypeBuilder entityTypeBuilder) 在Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.ConventionDispatcher.ImmediateConventionScope.OnEntityTypeAdded(InternalEntityTypeBuilderEntityTypeBuilder)中 在Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.ConventionDispatcher.RunVisitor.VisitOnEntityTypeAdded(OnEntityTypeAddedNode节点)处 在Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.ConventionDispatcher.ConventionVisitor.VisitConventionScope(ConventionScope节点) 在Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.ConventionDispatcher.ConventionVisitor.VisitConventionScope(ConventionScope节点) 在Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.ConventionDispatcher.ConventionBatch.Run() 在Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.RelationshipDiscoveryConvention.DiscoverRelationships(InternalEntityTypeBuilder entityTypeBuilder)...

Blockquote System.NotImplementedException: The 'MySQLNumberTypeMapping' does not support value conversions. Support for value conversions typically requires changes in the database provider. at Microsoft.EntityFrameworkCore.Storage.RelationalTypeMapping.Clone(ValueConverter converter) at Microsoft.EntityFrameworkCore.Storage.RelationalTypeMappingSource.b__7_0(ValueTuple3 k) at System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey key, Func2 valueFactory) at Microsoft.EntityFrameworkCore.Storage.RelationalTypeMappingSource.FindMappingWithConversion(RelationalTypeMappingInfo& mappingInfo, IReadOnlyList1 principals) at Microsoft.EntityFrameworkCore.Storage.RelationalTypeMappingSource.FindMapping(MemberInfo member) at Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.PropertyDiscoveryConvention.IsCandidatePrimitiveProperty(PropertyInfo propertyInfo) at Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.PropertyDiscoveryConvention.Apply(InternalEntityTypeBuilder entityTypeBuilder) at Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.ConventionDispatcher.ImmediateConventionScope.OnEntityTypeAdded(InternalEntityTypeBuilder entityTypeBuilder) at Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.ConventionDispatcher.RunVisitor.VisitOnEntityTypeAdded(OnEntityTypeAddedNode node) at Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.ConventionDispatcher.ConventionVisitor.VisitConventionScope(ConventionScope node) at Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.ConventionDispatcher.ConventionVisitor.VisitConventionScope(ConventionScope node) at Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.ConventionDispatcher.ConventionBatch.Run() at Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.RelationshipDiscoveryConvention.DiscoverRelationships(InternalEntityTypeBuilder entityTypeBuilder) ...

"MySQLNumberTypeMapping"不支持值转换.支持值转换通常需要更改数据库提供程序.

以下是我可能会创建的表中的内容:(我删除了对DataType(*)的任何引用,或者列举了我可能是MySQL可能存在的枚举.

Here's on of the tables im expected to get created: (I've removed any reference to DataType(*) or enums that I though might be the issue with MySQL.

[Key]
public int ID { get; set; }
[StringLength(50)]
public string Name { get; set; }
public int? PropertyID { get; set; }
public Property Property { get; set; }

//public SelectList Animals { get; set; }
//public string AnimalTypes { get; set; }
[Display(Name="Spesie")]
public int? AnimalTypeID { get; set; }
[Display(Name = "Spesie")]
public AnimalType AnimalType { get; set; }

public bool Male { get; set; }
public bool Trophy { get; set; }
public int Quantity { get; set; }
[DisplayFormat(ApplyFormatInEditMode = false, DataFormatString = "R{0:N}")]
public decimal Price { get; set; }
[StringLength(2000)]
public string Comments { get; set; }

为什么MySQL不喜欢这些定义?或此值转换试图执行什么操作?

Why is MySQL not liking these definitions? or what is this value conversions its trying to do?

推荐答案

为了继续开发,我发现合适的解决方案是

In order to continue development I found a suitable solution was to

安装软件包Pomelo.EntityFrameworkCore.Mysql -version 2.1.0-rc1-final

Install-Package Pomelo.EntityFrameworkCore.Mysql -version 2.1.0-rc1-final

使用nuget控制台并修改options的任何引用.将MySQL用作options.UseMySql.

using nuget console and modify any reference of options.UseMySQL to options.UseMySql.

这使我可以继续使用dotnet 2.1并利用mysql数据库.

This allowed me to continue with dotnet 2.1 and utilize a mysql database.

希望这会有所帮助!

这篇关于MySQLNumberTypeMapping'不支持值转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆