Open osmozis opened 3 weeks ago
I'm encountering the same issue. When using composite keys the GetJoinConditionSql in CommonUtil.cs will add "AND" without any spaces when building the query.
Compare this to the same method in the N.EntityFramework.Extensions where it will instead add " AND " with spaces. N.EntityFrameworkCore.Extensions: N.EntityFramework.Extensions:
Hopefully this should be all thats needed to fix the issue 😄
dbContext.BulkMerge() method generates exception "Unable to drop table '#tmp_be_xx...' because it doesn't exist or you don't have permissions"
This kind of exception only thrown in case of using composite primary key as in
modelBuilder.Entity<Example>()
.Property(x => x.Key1)
.Property(x => x.Key2)
.HasKey(x => new { x.Key1, x.Key2 })
The problem happens due to wrong SQL code generated for the MERGE query
MERGE [Example] AS t USING [#tmp_be_xx_Example] AS s ON t.Key1=s.Key1ANDt.Key2=s.Key2......
<- there are no spaces around 'AND' keywordThere are actually 2 exceptions: -first exception is about wrong SQL statement, but it is being swallowed by the library -the second one is about temp table dropping error that happens during BulkOperation.Dispose