Mono 2.8 sqlmetal

135 views
Skip to first unread message

Sandro

unread,
Oct 27, 2010, 10:20:54 AM10/27/10
to DbLinq
I upgraded to Mono 2.8, and tried to use sqlmetal (see [1] for prior
attempts). Mono still requires the SQL Server Browser service to be
running, otherwise it can't resolve instance names (unlike MS.NET).

In any case, sqlmetal chugs along then hits an
InvalidOperationException:

>>> Reading schema from SqlServer database
sqlmetal: System.InvalidOperationException: Operation is not valid due
to the current state of the object
at System.Linq.Enumerable.Single[Association] (IEnumerable`1 source,
System.Func`2 predicate, Fallback fallback) [0x00000] in <filename
unknown>:0
at System.Linq.Enumerable.Single[Association] (IEnumerable`1 source,
System.Func`2 predicate) [0x00000] in <filename unknown>:0
at DbMetal.Generator.Implementation.Processor.ValidateAssociations
(DbLinq.Schema.Dbml.Database database, DbLinq.Schema.Dbml.Table table)
[0x00000] in <filename unknown>:0
at DbMetal.Generator.Implementation.Processor.SchemaIsV
id (DbLinq.Schema.Dbml.Database database) [0x00000] in <filename
unknown>:0
at DbMetal.Generator.Implementation.Processor.ProcessSchema
(DbMetal.Parameters parameters) [0x00000] in <filename unknown>:0


Any thoughts?

Sandro

[1] http://groups.google.com/group/dblinq/browse_thread/thread/afc31ecc3463d8f2/ea6a43d40d49217a?lnk=gst#ea6a43d40d49217a

Jo

unread,
May 3, 2011, 4:08:50 AM5/3/11
to dbl...@googlegroups.com
Hi,
I have a similar problem.
Did you already solve this?

Regards,
Jo.

naas...@gmail.com

unread,
Jun 25, 2012, 4:19:13 PM6/25/12
to dbl...@googlegroups.com
Just an update that the problems I describe below still exist in the Mono 2.11 release.

Sandro

ohno...@gmail.com

unread,
Oct 25, 2012, 11:08:12 PM10/25/12
to dbl...@googlegroups.com, naas...@gmail.com
I hit the same error in Mono 2.10, which I am using because it’s marked stable in my distro. The sqlmetal shipped with mono seems useless. It assumes that you want to specify parameters for connecting to the database:

ohnobinki@gentoodcxdelllappy /tmp $ sqlmetal --debug test.dbml
DbLinq Database mapping generator 2008 version 0.20
for Microsoft (R) .NET Framework version 3.5
Distributed under the MIT licence (http://linq.to/db/license)

>>> Reading schema from DBML file 'test.dbml'
LoaderFactory.Load(schemaType=SqlServerSchemaLoader, dbConnType=SqlConnection)
Failed on Activator.CreateInstance(SqlConnection)
LoaderFactory.Load() failed: Object reference not set to an instance of an object
sqlmetal: System.NullReferenceException: Object reference not set to an instance of an object
  at DbLinq.SqlServer.SqlServerVendor.AppendServer (System.Text.StringBuilder connectionString, System.String host) [0x00000] in <filename unknown>:0
  at DbLinq.Vendor.Implementation.Vendor.BuildConnectionString (System.String host, System.String databaseName, System.String userName, System.String password) [0x00000] in <filename unknown>:0
  at DbMetal.Generator.Implementation.SchemaLoaderFactory.Load (DbMetal.Parameters parameters, System.Type dbLinqSchemaLoaderType, System.Type databaseConnectionType, System.Type sqlDialectType) [0x00000] in <filename unknown>:0
ohnobinki@gentoodcxdelllappy /tmp $

You can trick it out of this, make BuildConnectionString() happy, by just specifying -s:junk, like:

ohnobinki@gentoodcxdelllappy /tmp $ sqlmetal --debug -s:junk test.dbml
DbLinq Database mapping generator 2008 version 0.20
for Microsoft (R) .NET Framework version 3.5
Distributed under the MIT licence (http://linq.to/db/license)

>>> Reading schema from DBML file 'test.dbml'

sqlmetal: System.InvalidOperationException: Operation is not valid due to the current state of the object
  at System.Linq.Enumerable.Single[Column] (IEnumerable`1 source, System.Func`2 predicate, Fallback fallback) [0x00000] in <filename unknown>:0
  at System.Linq.Enumerable.Single[Column] (IEnumerable`1 source, System.Func`2 predicate) [0x00000] in <filename unknown>:0
  at DbMetal.Generator.Implementation.Processor.ValidateAssociations (DbLinq.Schema.Dbml.Database database, DbLinq.Schema.Dbml.Table table) [0x00000] in <filename unknown>:0
  at DbMetal.Generator.Implementation.Processor.SchemaIsValid (DbLinq.Schema.Dbml.Database database) [0x00000] in <filename unknown>:0
  at DbMetal.Generator.Implementation.Processor.ProcessSchema (DbMetal.Parameters parameters) [0x00000] in <filename unknown>:0
ohnobinki@gentoodcxdelllappy /tmp $

and then you end up with the error that everyone here seems stuck at. If I’m at fault, it’d be awesome to know what I need to fix in my use of sqlmetal ;-).

--
binki
Reply all
Reply to author
Forward
0 new messages