我正在测试mysql服务器5.7.17,我已将sql-mode定义为
sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
运行其中的每一个都给我定义了sql-mode:
SELECT @@sql_mode;
SELECT @@GLOBAL.sql_mode;
SELECT @@SESSION.sql_mode;
但是在我的vs2012桌面应用程序上使用带有EF6的mysql .net连接器6.9.8我总是收到错误
InnerException: MySql.Data.MySqlClient.MySqlException
HResult=-2147467259
Message=Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'punto_dia.Id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
Source=MySql.Data
ErrorCode=-2147467259
Number=1055
StackTrace:
en MySql.Data.MySqlClient.MySqlStream.ReadPacket()
en MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int64& insertedId)
en MySql.Data.MySqlClient.Driver.GetResult(Int32 statementId, Int32& affectedRows, Int64& insertedId)
en MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force)
en MySql.Data.MySqlClient.MySqlDataReader.NextResult()
en MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
en MySql.Data.Entity.EFMySqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
en System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
en System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.<Reader>b__c(DbCommand t, DbCommandInterceptionContext`1 c)
en System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext,TResult](TTarget target, Func`3 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed)
en System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.Reader(DbCommand command, DbCommandInterceptionContext interceptionContext)
en System.Data.Entity.Internal.InterceptableDbCommand.ExecuteDbDataReader(CommandBehavior behavior)
en System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
en System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)
我知道修复查询以正确使用GROUP BY我解决了错误,但是如果想使用查询,因为我使用mysql server 5.6.35为什么我不能?
sql-mode没有定义only_full_group_by
,所以我不明白为什么会出现这个错误。
有什么想法吗? 感谢