Linq to Sql

From $1
    Table of contents

    Sql Metal Integration

    Currently only available on svn version  with mono 2.6.x

    MonoDevelop Database Addin implements SqlMetal integration. The responsive addin for this integration is MonoDevelop.Database.CodeGenerator:


     How to Use it

    This addin insert 2 Tools menu at:

    • Tools - Database - Generate Linq Class

    Project Tools Menu.png

    • Right click on a Project or a folder - Tools Menu - Generate Linq Class

    Tools Menu.png

    Creating a new Linq to SQL Class

    Clicking on any of the above detailed menus you'll see a dialog like the following:

    Generate Linq Class.png

    In this dialog you will have to select the Database Connection.

    This connection could be added in this dialog by clicking New or you can Edit the selected connection.

    The output options are the generated output (Code or Dbml file), target language, case style,anfilename.

    The target project has to be selected and if it is needed the folder of the target project to. The namespace is the class namespace of the generated file.

    After filling all the required information, you must press OK and the file will be generated and added to the project.



    Tag page
    • No tags

    Files (4)

    FileSizeDateAttached by 
    No description
    76.77 kB01:43, 16 Feb 2010lucian0c?Actions
    Generate Linq Class.png
    No description
    44.51 kB02:10, 16 Feb 2010lucian0c?Actions
    Project Tools Menu.png
    No description
    36.62 kB02:06, 16 Feb 2010lucian0c?Actions
    Tools Menu.png
    No description
    83.55 kB01:59, 16 Feb 2010lucian0c?Actions
    Viewing 6 of 6 comments: view all
    This looks like a great feature, however I tried running this on Mac OS X (Snow Leopard) against a mySql database and received the error below. I'm running MonoDevelop 2.4 on Mono 2.6.4_3.

    I verified the connection to my mySql database by executing a query against one of the tables in it through the MonoDevelop interface. I chose the same connection for generating the Linq class.

    It wasn't clear to me from your post if I'm supposed to enter information for Entity Base, Entity Attributes, Member Attributes, or Generate Type, so I left those blank.

    Is this a bug or am I doing something wrong?

    MonoDevelop.Database.Sql.SqlMetalExecException: sqlmetal failed:ByteFX.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 '?db' at line 3
    at ByteFX.Data.MySqlClient.Driver.ReadPacket () [0x00000] in <filename unknown>:0
    at ByteFX.Data.MySqlClient.Driver.Send (DBCmd cmd, System.Byte[] bytes) [0x00000] in <filename unknown>:0
    at ByteFX.Data.MySqlClient.MySqlCommand.ExecuteBatch (Boolean stopAtResultSet) [0x00000] in <filename unknown>:0
    at (wrapper remoting-invoke-with-check) ByteFX.Data.MySqlClient.MySqlCommand:ExecuteBatch (bool)
    at ByteFX.Data.MySqlClient.MySqlDataReader.NextResult () [0x00000] in <filename unknown>:0
    at (wrapper remoting-invoke-with-check) ByteFX.Data.MySqlClient.MySqlDataReader:NextResult ()
    at ByteFX.Data.MySqlClient.MySqlCommand.ExecuteReader (CommandBehavior behavior) [0x00000] in <filename unknown>:0
    at ByteFX.Data.MySqlClient.MySqlCommand.ExecuteReader () [0x00000] in <filename unknown>:0
    at ByteFX.Data.MySqlClient.MySqlCommand.System.Data.IDbCommand.ExecuteReader () [0x00000] in <filename unknown>:0
    at DbLinq.Util.DataCommand.Find[IDataName] (IDbConnection conn, System.String sql, System.String dbParameterName, System.String db, System.Func`2 readDelegate) [0x00000] in <filename unknown>:0
    at DbLinq.MySql.MySqlSchemaLoader.ReadTables (IDbConnection connectionString, System.String databaseName) [0x00000] in <filename unknown>:0
    at DbLinq.Vendor.Implementation.SchemaLoader.LoadTables (DbLinq.Schema.Dbml.Database schema, DbLinq.Schema.SchemaName schemaName, IDbConnection conn, INameAliases nameAliases, DbLinq.Schema.NameFormat nameFormat, DbLinq.Vendor.Implementation.Names names) [0x00000] in <filename unknown>:0
    at DbLinq.Vendor.Implementation.SchemaLoader.Load (System.String databaseName, INameAliases nameAliases, DbLinq.Schema.NameFormat nameFormat, Boolean loadStoredProcedures, System.String contextNamespace, System.String entityNamespace) [0x00000] in <filename unknown>:0
    at DbMetal.Generator.Implementation.Processor.ReadSchema (DbMetal.Parameters parameters, ISchemaLoader& schemaLoader) [0x00000] in <filename unknown>:0
    at DbMetal.Generator.Implementation.Processor.ProcessSchema (DbMetal.Parameters parameters) [0x00000] in <filename unknown>:0
    Posted 00:11, 27 Jun 2010
    Thanks for this documentation!

    I was wondering how to generate the Model in a MonoDevelop MVC project and I figured "Linq to Sql" would provide some useful code. Sadly on my Ubuntu 10.10 (yup alpha) I get an error: "MonoDevelop.Database.Sql.SqlMetalExecException: sqlmetal: Object reference not set to an instance of an object". I wonder if this is because I just selected the Connection and left Base, Attributes, Member & Type empty.

    I know the previous comment was posted 18:11. 27 Jun 2010 and it's probably unwise of me to hope for an answer, but; I've always been a little crazy.

    Version: monodevelop 2.4+dfsg-1ubuntu1 Development Environment for GNOME
    Posted 11:03, 22 Aug 2010
    Well, I filled in EntityBase, EntityAttributes, MemberAttributes, and GeneratedType with those values and got 'MonoDevelop.Database.Sql.SqlMetalExecException: sqlmetal: Could not find file "/entityBase:EntityBase".'
    Posted 11:06, 22 Aug 2010
    Blank EntityBase and the other 3 filled in gets 'MonoDevelop.Database.Sql.SqlMetalExecException: sqlmetal: Could not find file "/entityAttributes:EntityAttributes".'
    Posted 11:08, 22 Aug 2010
    who can help me!? I have a problem !
    MonoDevelop.Database.Sql.SqlMetalExecException: sqlmetal: Could not find file "/entityBase:rick"?
    email me ? !
    Posted 09:07, 9 May 2011
    More than a year later and no response to these questions or issues; that seems odd to me. I'm wondering if, somehow, the mono folks would like to hear what their community has to say? Perhaps my lesson from this is that I should submit bugs (as described here here
    Posted 15:32, 2 Oct 2011
    Viewing 6 of 6 comments: view all
    You must login to post a comment.
    Page last modified 14:28, 16 Feb 2010 by lucian0c?