Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/278.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/entity-framework/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 插入大量数据实体框架7(核心),UWP_C#_Entity Framework_Sqlite_Win Universal App_Entity Framework Core - Fatal编程技术网

C# 插入大量数据实体框架7(核心),UWP

C# 插入大量数据实体框架7(核心),UWP,c#,entity-framework,sqlite,win-universal-app,entity-framework-core,C#,Entity Framework,Sqlite,Win Universal App,Entity Framework Core,在实体框架7中,我存储字典中的单词,其结构如下: [Table("Dictionaries")] public class Dictionary { public int DictionaryId { get; set; } public string Name { get; set; } public virtual List<Word> Words { get; set; } } [Table("Words")] public class Word {

在实体框架7中,我存储字典中的单词,其结构如下:

[Table("Dictionaries")]
public class Dictionary
{
    public int DictionaryId { get; set; }
    public string Name { get; set; }

    public virtual List<Word> Words { get; set; }
}

[Table("Words")]
public class Word
{
    public int WordId { get; set; }
    public string Text { get; set; }
    public int DictionaryId { get; set; }

    public Dictionary Dictionary { get; set; }
}

public class DictionaryContext : DbContext
{
    public DbSet<Dictionary> Dictionaries { get; set; }
    public DbSet<Word> Words { get; set; }
}
var dictionary = new Dictionary {
    Name = jsonDictionary.Name,
    Words = GetWords()
};
大约有9万字。我想快点把它存起来。 我试过:

db.ChangeTracker.AutoDetectChangesEnabled = false;
db.ChangeTracker.QueryTrackingBehavior = Microsoft.Data.Entity.QueryTrackingBehavior.NoTracking;
db.Dictionaries.Add(dictionary); // Lasts 1874.789 seconds
await db.SaveChangesAsync(); // Lasts 740.840
在一台速度很快的电脑里几乎需要一个小时。我试过几次反复思考,比如将单词存储在100、1000块中,但所有的测试都非常慢


有没有办法在SQLite中快速存储大量的数据?

您是否尝试过并行添加它们?谢谢,但这似乎不是并行问题。处理器以100%的速度工作。