Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
sqlmetal produces error with mysql database
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
El  
View profile  
 More options Dec 10 2010, 5:40 pm
From: El <ellory...@dasarchitekt.com>
Date: Fri, 10 Dec 2010 14:40:06 -0800 (PST)
Local: Fri, Dec 10 2010 5:40 pm
Subject: sqlmetal produces error with mysql database
Hello,

I have a MySQL database with a few tables which have indexes and
identifying as well as non-identifying relationships established (i.e.
primary and foreign keys, constraints).  I also have about 20 tables
in this database.

I am trying to create the objects using sqlmetal on Ubuntu Linux.  The
command I use is as follows:

sqlmetal /provider:MySQL /server:localhost /database:mydbname /
user:myuser /passwo
rd:mypassword /pluralize /debug /namespace=tpems.Model /
code=TpemsDbModel.cs

I get an number of errors when I run the command (see below for the
debug output).  I am able to generate using very simple (1 or 2
tables).  What am I doing wrong?  Anyone please help!  Thank you.

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 MySQL database

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

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jonathan Pryor  
View profile  
 More options Dec 11 2010, 9:45 am
From: Jonathan Pryor <jonpr...@vt.edu>
Date: Sat, 11 Dec 2010 09:45:47 -0500
Local: Sat, Dec 11 2010 9:45 am
Subject: Re: [dblinq] sqlmetal produces error with mysql database
On Dec 10, 2010, at 5:40 PM, El wrote:

> I get an number of errors when I run the command (see below for the
> debug output).  I am able to generate using very simple (1 or 2
> tables).  What am I doing wrong?  Anyone please help!  Thank you

sqlmetal doesn't like your tables.  The relevant code is:

                var otherType           = database.Tables.Single(t => t.Type.Name == association.Type).Type;
                var otherAssociation    = otherType.Associations.Single(a => a.Type == table.Type.Name && a.ThisKey == association.OtherKey);
                var otherColumn         = otherType.Columns.Single(c => c.Member == association.OtherKey);

                if (association.CardinalitySpecified && association.Cardinality == Cardinality.Many && association.IsForeignKey)
                {
                    error = true;
                    Log.WriteErrorLine("Error DBML1059: The IsForeignKey attribute of the Association element '{0}' of the Type element '{1}' cannnot be '{2}' when the Cardinality attribute is '{3}'.",
                            association.Name, table.Type.Name, association.IsForeignKey, association.Cardinality);
                }

So one of those .Single() calls is failing because either 0 items are present or more than one item is present, thus preventing sqlmetal from further validating your schema (and possibly generating other errors).

To narrow down which line is failing, run your command with MONO_OPTIONS set:

        $ MONO_OPTIONS=--debug sqlmetal ...

That should provide line numbers in the exception message.

The intent of the above block of code is to ensure that the table cross-references are "sane" -- that for an association:

 1. There is only one matching Type for the association.
 2. The matched type (1) has an association to the "current" association, i.e. it's bidirectional
 3. The referenced column in the matching type (1) actually exists.

In a well normalized table schema, these should all be valid, but it's fairly easy to break this...

 - Jon


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jo  
View profile  
 More options May 3 2011, 6:40 am
From: Jo <johannes.rie...@gmail.com>
Date: Tue, 3 May 2011 03:40:48 -0700 (PDT)
Local: Tues, May 3 2011 6:40 am
Subject: Re: [dblinq] sqlmetal produces error with mysql database

I had the same problem. Im my case the violated condition was 3.
The reason for that was that I had a .dbml File created in Visual Studio. In
this file the column attributes "Storage" and "Member" were missing -
obviously they are not required in VS.
I added these attributes in my .dbml with the same values as "Name" -
worked.

Regards,
Jo.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jo  
View profile  
 More options May 3 2011, 6:49 am
From: Jo <johannes.rie...@gmail.com>
Date: Tue, 3 May 2011 03:49:38 -0700 (PDT)
Local: Tues, May 3 2011 6:49 am
Subject: Re: [dblinq] sqlmetal produces error with mysql database

Now I ran into another problem. I am using keys consisting of two fields.

      <Association Name="DBActivity_DBActivityProperty" Member="DBActivity"
ThisKey="ActivityUserID,ActivityMobileID" OtherKey="UserID,MobileId"
Type="DBActivity" IsForeignKey="true" />

Obviously the check for the 3rd condition will not work for
"UserID,MobileId".
Are keys consisting of more than 1 column not supported?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »