-
-
Notifications
You must be signed in to change notification settings - Fork 597
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
BulkInsert not working #1349
Comments
If I use AddRange for the not working example, it works. I am therefore sure that both the tables and columns exist. |
After 13 hours of testing and 14 minutes after making this post, I figured out the problem. BulkInsert cannot handle schemas!
When I removed this line of code, it worked. Perhaps you want to check that out. |
Could you add entire code of class GridInfoEntity and GridInfoZEntity or write a Test for the issue. |
Yes, of couse. See below (screenshot for readability + copy paste): [Table("GridInfo", Schema = "Domain")] [Table("GridInfo.X", Schema = "Domain")]
} Exactly the same applies to the Y and Z variant (I double checked in my code). And for the Brep-chain: public class BrepEntity : Entity public class PolygonEntity : Entity public class VectorEntity : Entity
} |
The only difference appears to be the schema. Once I removed it, everything worked as expected. And I remember from last week that I got exception that actually used the schema name. It said that the schema name did not exist (while it definitely did). I guess somewhere in your code, you are not handling schemas. Is that possible? For now, I disabled schemas in my code base (hopefully temporarily, because my database is not nicely structured anymore when viewing it in SMSS). |
Schemas are actually supported with main Bulk ops. |
How do you mean that exactly? I interpreted IncludeGraph as: include all children so that all gets added. In this particular example, you mean storing the X-values, Y-values, Z-values and grid infos themselves as separate calls? I guess that would work here, but in my actual project this would get too messy (I have referred a different post 38 minutes ago). I can live with not having schemas for the time being. |
Yes, that's right. |
Thank you Boris for you quick replies. I will keep an eye on this post and would be more than happy to contribute to solving this problem wherever I can. Just let me know. |
Why does this work?
List<BrepEntity> brepjes = new List<BrepEntity>();
for (int i = 0; i < 100; i++)
{
brepjes.Add(new BrepEntity()
{
Polygons = new List<PolygonEntity>()
{
new PolygonEntity()
{
Vertices = new List<VectorEntity>()
{
new VectorEntity() { X = 123, Y = 2348.324f, Z = 234293784.1f },
}
},
new PolygonEntity()
{
Vertices = new List<VectorEntity>()
{
new VectorEntity() { X = 334, Y = 244648.324f, Z = 909793784.1f },
}
}
}
});
}
Stopwatch stopwatch = Stopwatch.StartNew();
_context.BulkInsert(brepjes, options => options.IncludeGraph = true);
_context.BulkSaveChanges();
stopwatch.Stop();
return stopwatch.ElapsedMilliseconds;
But this does not?
List<GridInfoEntity> test = new List<GridInfoEntity>()
{
new GridInfoEntity()
{
GridInfoX = new List<GridInfoXEntity>()
{
new GridInfoXEntity("Label", 123),
},
GridInfoY = new List<GridInfoYEntity>()
{
new GridInfoYEntity("Label", 456),
},
GridInfoZ = new List<GridInfoZEntity>()
{
new GridInfoZEntity("Label", 789),
},
}
};
Stopwatch stopwatch = Stopwatch.StartNew();
_context.BulkInsert(test, options => options.IncludeGraph = true);
_context.BulkSaveChanges();
stopwatch.Stop();
return stopwatch.ElapsedMilliseconds;
I am getting this error, which is incorrect:
Missing Column : GridInfoId
On entity : GridInfoXEntity
On Table : [Domain].[GridInfo]
The text was updated successfully, but these errors were encountered: