[Mono-list] Multiple issues with sqlmetal and MySql

st0p frankdeweger at hotmail.com
Thu Nov 4 14:12:31 EDT 2010

I've been trying for a couple of days now to use LINQ and MySql under Mono /
Win7. After finding out that I needed to change sqlmetal.exe.config, finally
the sqlmetal produced some code. It compiles fine but gives me multiple

1) I need to manually change the code, if I leave AutoSync=AutoSync.Never on
the PK column, it will trigger an exception. Changing it to
AutoSync.OnInsert works though.

2) When I create an instance of the generated DataContext, using a MySql
connection object, I´m getting the following generated sql:
SELECT [t0].[Email], [t0].[Id] AS [ID], [t0].[Password]
FROM [rss].[user] AS [t0]
-- Context: SqlProvider(Sql2008) Model: AttributedMetaModel Build:
As you can see, the provider seems to be MSSql instead of MySql

This triggers the following exeption:
MySql.Data.MySqlClient.MySqlException: You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version for the 

right syntax to use near '[t0].[Email], [t0].[Id] AS [ID], [t0].[Password]
FROM [rss].[user] AS [t0]' at line 1
   at MySql.Data.MySqlClient.MySqlStream.ReadPacket()
   at MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow,
Int32& insertedId)
   at MySql.Data.MySqlClient.Driver.GetResult(Int32 statementId, Int32&
affectedRows, Int32& insertedId)
   at MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId)
   at MySql.Data.MySqlClient.MySqlDataReader.NextResult()
   at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior
   at System.Data.Common.DbCommand.ExecuteReader()
   at System.Data.Linq.SqlClient.SqlProvider.Execute(Expression query,
QueryInfo queryInfo, IObjectReaderFactory factory, Object[] parentArgs,

userArgs, ICompiledSubQuery[] subQueries, Object lastResult)
   at System.Data.Linq.SqlClient.SqlProvider.ExecuteAll(Expression query,
QueryInfo[] queryInfos, IObjectReaderFactory factory, Object[]

ICompiledSubQuery[] subQueries)
   at Reader.MainClass.Main(String[] args) in
c:\Users\frank\Documents\Projects\Reader\Reader\Main.cs:line 58

When I try to instantiate the context class using a connection string, it
also tries to connect to a MsSql server and thus times out.

Does anybody know what I´m doing wrong=

View this message in context: http://mono.1490590.n4.nabble.com/Multiple-issues-with-sqlmetal-and-MySql-tp3027505p3027505.html
Sent from the Mono - General mailing list archive at Nabble.com.

More information about the Mono-list mailing list