The argument 'sql' cannot be null, empty or contain only white space. When first create the database

c# entity-framework-6 sqlite

Question

I'm using entity framework to process the sqlite database. If there's no database and I want to insert one record, it will create the database successfully (I found the database file in disk) but throw the error:

The argument 'sql' cannot be null, empty or contain only white space.".

Then next time running, because the database has been created, all code works well with no error.

DbContext.Database.ExecuteSqlCommand(sqlCmd, parameters.ToArray());

Only throw above error when Database not exist. If exist, work well.

1
0
7/30/2019 10:22:43 AM

Popular Answer

This error may occur in case the "sqlCmd" variable is null or empty when the ExecuteSqlCommand method is called. Please make sure that this variable is correctly initialized in case the database does not exist.

0
7/30/2019 7:38:00 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow