Closed JasonRodman closed 1 year ago
JasonRodman,
I have tried several times to replicate your issue but I have not been able to get it to error at all.
Please provide more details about the error that is thrown like the stack trace and any other relevant data I could use to trace it.
You may want to download the source code and use it instead of the nuget library to step through the code to figure out why it is erroring.
I spent a day and tried to pinpoint where the code was failing too. The stack trace gives me no insight. So, resorted to using reflection to recreate what your BulkInsertAsync
[JsonConverter(typeof(StringEnumConverter))]
public JobStatus Status { get; private set; }
[JsonIgnore]
public string StatusValue
{
get => Status.ToString();
set => Status = value.ToEnum<JobStatus>();
}
Another cause may be the accessibility of my properties. Most of them have private setters, and the identity is protected internal. This is on purpose due to using DDD as our architectural pattern for these entities, only allowing change thru methods. EF handles settings these properties just fine though. This entity also uses an integer identity column as well as a timestamp column marked as [RowVersion] for optimistic concurrency. I am not sure which of these were the cause, but hopefully this will help you find which one is.
JasonRodman,
I tried the following without any errors:
This is what the Product class looks like in my test code:
`public class Product {
[Key]
public int Id { get; set; }
public string Name { get; set; }
public double? Price { get; set; }
[JsonConverter(typeof(StringEnumConverter))]
public ProductStatus Status { get; private set; }
[JsonIgnore]
public string StatusValue
{
get => Status.ToString();
set => Status = (ProductStatus)Enum.Parse(typeof(ProductStatus), value);
}
public DateTime AddedDate { get; set; }
[Timestamp]
public byte[] RowVersion { get; set; }
}`
When I set the Id to be protected internal, the framework complains that no key exists on the class and this is a validation error generated by EF.
A couple of other things you could try
JasonRodman,
I just pushed a new version v1.7.2 to nuget that takes care of properties that use the Timestamp attribute so you will no longer need to explicitly omit that property using the IgnoreColumns option.
Issue can't be reproduced.
I am trying your library for the first time but I cannot seem to get it to work. I am simply trying to bulk insert a bunch of rows while ignoring a timestamp column that is used for optimistic concurrency. I cant seem to get any detail out of the error that leads me to what could be causing the error. There may be something specific to the setup of my datacontext that your library does not handle but I have no way to find out what that is. I am trying to go step by step based on your code to see if I can reproduce what your code does to find the issue, but so far I have not found the issue. Any ideas how I can troubleshoot this?
await context.BulkInsertAsync(recordsToAdd, options => { options.UsePermanentTable = true; options.IgnoreColumns = o => new { o.RowVersion }; });