Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BulkInsertAsync does not seem to want to insert entries where the entry has a child entity that is null #1636

Open
snydesc opened this issue Dec 12, 2024 · 0 comments

Comments

@snydesc
Copy link

snydesc commented Dec 12, 2024

Given a model that looks like:

public class EntryA
{
   [Key]
   public int EntryAId { get; set; }

   public string? EntryBId { get; set; }
   
   [ForeignKey(nameof(EntryBId ))]
   public virtual EntryB? EntryB{ get; set; }
}
public class EntryB
{
   [Key]
   public string EntryBId { get; set; }
}

and then trying to insert the following

EntryA entryA = new EntryA()
{
   EntryAId = 1
}
List<EntryA> listOfEntryA = new List<EntryA>();
listOfEntryA.Add(entryA);

await context.BulkInsertOrUpdateAsync(listOfEntryA);
await context.BulkSaveChangesAsync();

will not throw any errors, but will not insert the entry.
If you populate EntryA.EntryBId with a valid id for a record in the EntryB table then it will get inserted.

making the same call with EFCore AddRangeAsync works fine
.
This is being inserted into a SQLite database.
The project is a .NET 9 MAUI app using EFCore 9 and Bulk Extensions 9.0.0-rc.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant