Description:
When I use MySql.EntityFrameworkCore 6.0.7, if I do not specify a database in my connection string, I get a "No database selected" exception when using the entities to select data with Linq statements. Oddly, When I use SaveChanges to insert records into the database, I do not get any errors. When I use MySql.EntityFrameworkCore 3.1.27, I can do all operations without any errors. Additionally, in both versions, I can use the underlying MySqlConnection to query the database, without specifying the database in the connection string. This seems like a bug with the .Net 6 versions of MySql.EntityFrameworkCore, since it was working fine in the old versions, plus my entities have the schema defined, so I should not have to supply that in the connection string.
Stack Trace: MySqlStream.ReadPacket() NativeDriver.GetResult(Int32& affectedRow, Int64& insertedId) Driver.GetResult(Int32 statementId, Int32& affectedRows, Int64& insertedId) Driver.NextResult(Int32 statementId, Boolean force) MySqlDataReader.NextResult() MySqlCommand.ExecuteReader(CommandBehavior behavior) MySqlCommand.ExecuteDbDataReader(CommandBehavior behavior) DbCommand.ExecuteReader() RelationalCommand.ExecuteReader(RelationalCommandParameterObject parameterObject) Enumerator.InitializeReader(Enumerator enumerator) <>c.b__19_0(DbContext _, Enumerator enumerator) MySQLExecutionStrategy.Execute[TState,TResult](TState state, Func3 operation, Func3 verifySucceeded) Enumerator.MoveNext() List1.ctor(IEnumerable1 collection) Enumerable.ToList[TSource](IEnumerable`1 source)
How to repeat:
Use MySQL entities to select data from a table, without database being in the connection string. This will work in version 3.1.27, but will throw an exception in version 6.0.7.
Suggested fix:
Allow all Entity Framework operations without specifying database in the connection string, since it is effectively already specified as the schema in the entity declaration.