My code:
dbContext.Database.ExecuteSqlCommand(
@"BULK INSERT dbo.tblAudit FROM @FileName WITH (FIRSTROW=2, FIELDTERMINATOR='|', ROWTERMINATOR='\n')",
new SqlParameter("@FileName", auditCsvFileName)
);
It should perform a bulk insert from a csv file.
It throws an error
System.Data.SqlClient.SqlException: Incorrect syntax near '@FileName'
I can run this command (with the filename inserted) in SSMS without an error.
Is this an invalid use of parameters?
Does Entity Framework not support
BULK INSERT
as a raw SQL command?
Thanks