Many to Many wrong table name

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
degas
Posts: 77
Joined: Mon 16 Feb 2009 18:36
Location: Argentina

Many to Many wrong table name

Post by degas » Thu 01 Aug 2013 21:00

I have a class called EntidadLegal. Then to more classes that extend EntidadLegal called Cargador and Cliente. The Cargador has a many to many relationshiop to Cargador. I have mapped the relationship as following:

Code: Select all

modelBuilder.Entity<Cliente>()
                .HasMany(u => u.Cargadores)
                .WithMany(c => c.Clientes).Map(f => f.MapLeftKey("ID_CLIENTE").MapRightKey("ID_CARGADOR").ToTable("DEGNET.CLIENTE_CARGADOR"));
The problem is that when i try to access this properties form Cliente (or Cargador) the sql generated is wrong because the table name is between "" like this

Code: Select all

SELECT 
'1X0X' AS C1,
"Join1".ID_ENTIDAD_LEGAL,
"Join1".NEMONICO,
"Join1".RAZON_SOCIAL,
"Join1".CUIT,
"Join1".FAX1 AS FAX,
"Join1".TELEFONO1 AS TELEFONO,
"Join1".MEGID,
"Join1".NOMBRE_PARA_TGN,
"Join1".RECIBE_FAX,
"Join1".FAX2 AS FAX1,
"Join1".TELEFONO2 AS TELEFONO1,
"Join1".EMAIL,
"Join1".RESPONSABLE,
"Join1".ID_CARGADOR_TGN
FROM  "DEGNET.CLIENTE_CARGADOR" "Extent1"  <----ERROR should be "DEGNET"."CLIENTE_CARGADOR"
INNER JOIN  (SELECT 
    "Extent2".ID_ENTIDAD_LEGAL,
    "Extent2".NEMONICO,
    "Extent2".RAZON_SOCIAL,
    "Extent2".CUIT,
    "Extent2".FAX AS FAX1,
    "Extent2".TELEFONO AS TELEFONO1,
    "Extent2".MEGID,
    "Extent3".ID_CARGADOR,
    "Extent3".NOMBRE_PARA_TGN,
    "Extent3".RECIBE_FAX,
    "Extent3".FAX AS FAX2,
    "Extent3".TELEFONO AS TELEFONO2,
    "Extent3".EMAIL,
    "Extent3".RESPONSABLE,
    "Extent3".ID_CARGADOR_TGN
    FROM  RED.ENTIDAD_LEGAL "Extent2"
    INNER JOIN RED.CARGADOR "Extent3" ON "Extent2".ID_ENTIDAD_LEGAL = "Extent3".ID_CARGADOR ) "Join1" ON "Extent1".ID_CARGADOR = "Join1".ID_ENTIDAD_LEGAL
WHERE "Extent1".ID_CLIENTE = :EntityKeyValue1

in order to fix this temporaly i have change the mapping to

Code: Select all

modelBuilder.Entity<Cliente>()
                .HasMany(u => u.Cargadores)
                .WithMany(c => c.Clientes).Map(f => f.MapLeftKey("ID_CLIENTE").MapRightKey("ID_CARGADOR").ToTable("DEGNET\".\"CLIENTE_CARGADOR"));
This workaround seems to work for the relationship, also when inserting in the table

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Many to Many wrong table name

Post by Shalex » Wed 07 Aug 2013 07:52

This is a designed behaviour.

You are using the following overload: http://msdn.microsoft.com/en-us/library ... 03%29.aspx.

Code: Select all

.ToTable("DEGNET.CLIENTE_CARGADOR");

Code: Select all

.ToTable("DEGNET\".\"CLIENTE_CARGADOR")
Please try this overload for setting schema name: http://msdn.microsoft.com/en-us/library ... 03%29.aspx.

Code: Select all

.ToTable("DEGNET", "CLIENTE_CARGADOR");

degas
Posts: 77
Joined: Mon 16 Feb 2009 18:36
Location: Argentina

Re: Many to Many wrong table name

Post by degas » Wed 07 Aug 2013 12:38

So sorry i wasted your time.

Post Reply