Open kenzouno1 opened 4 years ago
Thank you for reporting,
We will look at it.
Best Regards,
Jon
Performance Libraries
context.BulkInsert(list, options => options.BatchSize = 1000);
Entity Framework Extensions • Entity Framework Classic • Bulk Operations • Dapper Plus
Runtime Evaluation
Eval.Execute("x + y", new {x = 1, y = 2}); // return 3
C# Eval Function • SQL Eval Function
Hello @kenzouno1 ,
Could you provide a runnable code/project with this issue.
My developer tried it but didn't get a similar error;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.EntityFrameworkCore;
namespace lab.EFCore20.PostgreSQL
{
class Request_Update_IDDouble
{
public static void Execute()
{
bool createAndDeleteBD = true;
if (createAndDeleteBD)
{
// Create BD
using (var context = new EntityContext())
{
My.DeleteBD(context);
context.Database.EnsureCreated();
}
}
// CLEAN
using (var context = new EntityContext())
{
context.EntitySimples.RemoveRange(context.EntitySimples);
context.SaveChanges();
}
// SEED
using (var context = new EntityContext())
{
context.EntitySimples.Add(new EntitySimple { ColumnInt = 1 });
context.EntitySimples.Add(new EntitySimple { ColumnInt = 2 });
context.EntitySimples.Add(new EntitySimple { ColumnInt = 3 });
context.SaveChanges();
}
// TEST
using (var context = new EntityContext())
{
List<EntitySimple> list = new List<EntitySimple>();
list.Add(new EntitySimple { ColumnInt = 10 });
list.Add(new EntitySimple { ColumnInt = 11 });
list.Add(new EntitySimple { ColumnInt = 12 });
context.BulkInsert(list);
var listId = list.Select(x => x.ID).ToList();
// context.EntitySimples.Where(x => listId.Contains(x.ID)).Update(x => new EntitySimple() {ColumnString = "TEST"});
context.EntitySimples.Where(x => listId.Contains(x.ID)).UpdateFromQuery(x => new EntitySimple() {ColumnString = "TEST"});
var testaa = context.EntitySimples.ToList();
}
}
public class EntityContext : DbContext
{
public EntityContext()
{
}
public DbSet<EntitySimple> EntitySimples { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseNpgsql(My.Connection);
}
}
public class EntitySimple
{
public int ID { get; set; }
public int ColumnInt { get; set; }
public String ColumnString { get; set; }
}
}
}
Exactly this not working if Model has Property type ComplexType
. How to remove ComplexType Field on the query?
That is my code.
@JonathanMagnan UpdateDynamic.zip
Hello @kenzouno1 ,
Just to give you an update, we successfully reproduced the issue even on SQL Server by using your code.
My developer will try something this week by explicitly selecting column or by modifying the SQL to make sure column alias are unique.
I will keep you updated
Hello @kenzouno1 ,
It took us more time than expected but my developer successfully fixed the issue.
However, we only succeed to make the fix for EF Core 3.x ;(
I believe you currently use EF Core 2.x and for this version, we never found how to do it correctly since column alias are missing unlike EF Core 3.x
I think need a feature blacklist properties. Can you do that?
It depends,
Let us know more about your idea ;)
I'm not real .Net developer so I don't know how to do it.
But i think on query you need get all Properties
of Model. So why not have a feature add a Black List Property Names
and on query will remove it from List Properties before execute command
Hi @JonathanMagnan, does this fix has been published for ef core 3.x? If yes, in what version?
This error occurs when using auto include in the context mapping.
Example: modelBuilder.Entity
Try doing:
Description
Batch Update in EF Core with pgsql throw exception
column reference "Id" is ambiguous
My Code
Sql Command
Exception
If you are seeing an exception, include the full exceptions details (message and stack trace).
Further technical details