"No database selected" error for MySql with EF Core 6
Posted by: Eric Finch
Date: November 01, 2022 07:43AM

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)

Options: ReplyQuote


Subject
Written By
Posted
"No database selected" error for MySql with EF Core 6
November 01, 2022 07:43AM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.