1

i am trying to import tab delimitted feed to mysql using EFCore 2.0 and Pomelo libraries.

Feed is as below....

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

the code is as below

//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);
    }
}

I am getting the exception as below...

**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'

I configured the tag length as 256 everywhere like entity, table..etc but it is taking only 64 characters length ("BusinessCombinationRecognizedIdentifiableAssetsAcquiredAndLiabil") and causing the Duplicate Entry Exception.

please help me how to solve this? and let me know if more details required..

lauxjpn
  • 4,749
  • 1
  • 20
  • 40
  • another observation, if i keep only few records in feed like 100 its working fine without isues. but if i am trying to insert 67900 records..this kind of error happening – SRIKANTH DASARI Feb 11 '18 at 03:23
  • Please edit your question to include the complete `CREATE TABLE` statement of your `tag` table, including all the indices you have added to the table. You might want to look at https://stackoverflow.com/questions/11739014/how-to-generate-a-create-table-script-for-an-existing-table-in-phpmyadmin – Progman Feb 11 '18 at 10:34

0 Answers0