Quantcast
Channel: ADO.NET, Entity Framework, LINQ to SQL, NHibernate
Viewing all articles
Browse latest Browse all 1698

EF trying to select a column that doesn't exist (Oracle database)

$
0
0

Hello all,

I'm currently stumped by a strange EF Core + Oracle problem. When I include one of my tables, it's trying to select a column that doesn't exist (there's no column in the table, no properties in the entity framework object) and blowing up the query with anORA-00904 error

Here is the query that's failing:

var pogData = _context.UnvPog
   .Include(pog => pog.UnvPogFixture).ThenInclude(f => f.Fixture).ThenInclude(a => a.AccessoryType)
   .Include(pog => pog.UnvPogFixture).ThenInclude(f => f.Fixture).ThenInclude(a => a.SubAccessoryType)
   .Include(pog => pog.UnvPogGraphic).ThenInclude(f => f.Graphic).ThenInclude(a => a.AccessoryType)
   .Include(pog => pog.UnvPogGraphic).ThenInclude(f => f.Graphic).ThenInclude(a => a.SubAccessoryType).Include(pog => pog.UnvPogProduct).ThenInclude(f => f.Product).ThenInclude(a => a.AccessoryType).Include(pog => pog.UnvPogProduct).ThenInclude(f => f.Product).ThenInclude(a => a.SubAccessoryType)
   .Include(pog => pog.Company)
   .Include(pog => pog.Brand)
   .Include(pog => pog.RetailChain)
   .Single(p => p.PogId == _pogId);

The Include statements that are bold/italicized are the problem. If I comment out those two lines, the data is retrieved successfully. If I do not comment them out, I get the ORA-00904 error. Here is a screenshot of the exception just for your information (hopefully the image is visible, for some reason I always see the windows thumbnail icon instead of images on this website...? If you can't see the image, thislink will take you to the imgur of it):

Exception debugger

Here is the Entity from my dbContext (I stripped out a tiny bit of code that I 100% know is irrelevant just to keep it as short as possible):

modelBuilder.Entity<UnvPogProduct>(entity =>
{
	entity.HasKey(e => new { e.PogId, e.ShelfId, e.Posno })
		.HasName("UNV_POG_PRODUCT_PK");

	entity.ToTable("UNV_POG_PRODUCT");

	entity.HasIndex(e => new { e.PogId, e.ShelfId, e.Posno })
		.HasName("UNV_POG_PRODUCT_PK")
		.IsUnique();

	entity.Property(e => e.PogId).HasColumnName("POG_ID");

	entity.Property(e => e.ShelfId)
		.HasColumnName("SHELF_ID")
		.HasColumnType("VARCHAR2(200)");

	entity.Property(e => e.ProductDescriptiveName)
	.HasColumnName("PRODUCT_DESCRIPTIVE_NAME")
	.HasColumnType("VARCHAR2(200");


	entity.Property(e => e.ProductUpc)
		.IsRequired()
		.HasColumnName("PRODUCT_UPC")
		.HasColumnType("VARCHAR2(13)");

	entity.HasOne(d => d.Company)
		.WithMany(p => p.UnvPogProduct)
		.HasForeignKey(d => d.CompanyId)
		.OnDelete(DeleteBehavior.ClientSetNull)
		.HasConstraintName("UNV_POG_PRODUCT_FK1");

	entity.HasOne(d => d.Pog)
		.WithMany(p => p.UnvPogProduct)
		.HasForeignKey(d => d.PogId)
		.OnDelete(DeleteBehavior.ClientSetNull)
		.HasConstraintName("UNV_POG_PRODUCT_POG_FK");

});

Here is the schema of the UnvPogProduct database table, FYI:

table

Sorry for kind of just dumping a huge amount of information, but I wanted to include as much as possible to expose any spots that might be the issue. I cannot figure out what's causing EF to try and select a property called 

ProductFixtureId

that property does not exist anywhere in source code, nor is there is a column anywhere in the database that is related either.

I appreciate any advice, and if you need more information, please let me know.

Thanks,

Nick


Viewing all articles
Browse latest Browse all 1698

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>