I Need to run a simple left join on my database and it seems EFCore cannot do this job. I have this Query:
"SELECT ag.ID as AgreementId, " +
" sg.SignedAt ," +
" sg.SignedByName As SignedBy," +
" ag.Type As Type," +
" ag.Version," +
" sg.VendorId," +
" ag.CreatedAt As AgreementCreated " +
"from `Agreements` ag LEFT JOIN `SignedAgreements` sg on " +
" sg.`AgreementId`= ag.`Id` " +
" and sg.`VendorId` = @vendorId " +
"where ag.`Type` = @type";
and I need to generate this query using Linq or run it directly on dbContext.Database.SqlQueryRaw()
. So I attempted to translate this raw SQL to Linq but was unsuccessful. So, I was forced to run the query using the dbContext.Database.SqlQueryRaw
but I am facing this error:
System.InvalidOperationException: The element type 'VendorAgreementSignReadModel' used in 'SqlQuery' method is not natively supported by your database provider. Either use a supported element type, or use ModelConfigurationBuilder.DefaultTypeMapping to define a mapping for your type.
As this blog described this functionality is not supported until version 8 of EfCore.