Дублирующая ошибка ввода в EFCore и Mysql

Я пытаюсь импортировать ленту с разделителями табуляции в MySQL, используя библиотеки EFCore 2.0 и Pomelo.

Подача как ниже....

"BusinessCombinationRecognizedIdentifiableAssetsAcquiredAndLiabilitiesAssumedAssets"    "us-gaap/2016"
"BusinessCombinationRecognizedIdentifiableAssetsAcquiredAndLiabilitiesAssumedCashAndEquivalents" "us-gaap/2016"

код как ниже

//Entity Class
[Table("tags")]
public partial class tag:BaseEntity
{
    [Key]
    [Column("tag", Order = 0)]
    [StringLength(256)]
    [FeedOrder(0)]
    public string tag1 { get; set; }

    [Key]
    [Column(Order = 1)]
    [StringLength(20)]
    [FeedOrder(1)]
    public string version { get; set; }

}


//Context
public class VDContext:DbContext
{

    public virtual DbSet<tag> tags { get; set; }
    public VDContext(DbContextOptions options):base(options){ }

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        modelBuilder.Entity<tag>()
            .Property(e => e.tag1)
            .IsUnicode(false);

        modelBuilder.Entity<tag>()
            .Property(e => e.version)
            .IsUnicode(false);
    }
}

Я получаю исключение, как показано ниже...

**MySql.Data.MySqlClient.MySqlException (0x80004005): Duplicate entry 'BusinessCombinationRecognizedIdentifiableAssetsAcquiredAndLiabil' for key 'PRIMARY' ---> MySql.Data.MySqlClient.MySqlException (0x80004005): Duplicate entry 'BusinessCombinationRecognizedIdentifiableAssetsAcquiredAndLiabil' for key 'PRIMARY'**


at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable`1.ConfiguredValueTaskAwaiter.GetResult()
   at MySqlConnector.Core.ResultSet.<ReadResultSetHeaderAsync>d__1.MoveNext() in C:\projects\mysqlconnector\src\MySqlConnector\Core\ResultSet.cs:line 43
   at MySql.Data.MySqlClient.MySqlDataReader.ActivateResultSet(ResultSet resultSet) in C:\projects\mysqlconnector\src\MySqlConnector\MySql.Data.MySqlClient\MySqlDataReader.cs:line 92
   at MySql.Data.MySqlClient.MySqlDataReader.<ReadFirstResultSetAsync>d__65.MoveNext() in C:\projects\mysqlconnector\src\MySqlConnector\MySql.Data.MySqlClient\MySqlDataReader.cs:line 297
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at MySql.Data.MySqlClient.MySqlDataReader.<CreateAsync>d__64.MoveNext() in C:\projects\mysqlconnector\src\MySqlConnector\MySql.Data.MySqlClient\MySqlDataReader.cs:line 287
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at MySqlConnector.Core.TextCommandExecutor.<ExecuteReaderAsync>d__3.MoveNext() in C:\projects\mysqlconnector\src\MySqlConnector\Core\TextCommandExecutor.cs:line 70
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at MySql.Data.MySqlClient.MySqlCommand.ExecuteDbDataReader(CommandBehavior behavior) in C:\projects\mysqlconnector\src\MySqlConnector\MySql.Data.MySqlClient\MySqlCommand.cs:line 172
   at Microsoft.EntityFrameworkCore.Storage.Internal.MySqlRelationalCommand.<ExecuteAsync>d__3.MoveNext()
fail: Microsoft.EntityFrameworkCore.Update[10000]
      An exception occurred in the database while saving changes for context type 'vd.database.VDContext'.
      Microsoft.EntityFrameworkCore.DbUpdateException: An error occurred while updating the entries. See the inner exception for details. ---> MySql.Data.MySqlClient.MySqlException: Duplicate entry 'BusinessCombinationRecognizedIdentifiableAssetsAcquiredAndLiabil' for key 'PRIMARY' ---> MySql.Data.MySqlClient.MySqlException: Duplicate entry 'BusinessCombinationRecognizedIdentifiableAssetsAcquiredAndLiabil' for key 'PRIMARY'

Я настроил длину тега как 256 везде, например, entity, table..etc, но он принимает длину всего 64 символа ("BusinessCombinationRecognizedIdentifiableAssetsAcquiredAndLiabil") и вызывает исключение Duplicate Entry.

помогите пожалуйста как это решить? и дайте мне знать, если потребуется более подробная информация..

0 ответов

Другие вопросы по тегам