google-code-export / dblinq2007

Automatically exported from code.google.com/p/dblinq2007
Other
0 stars 0 forks source link

DbMetal: Element type System.CodeDom.CodeDefaultValueExpression is not supported. #259

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Software: dblinq 0.20.1 from source compiled with xbuild on OpenSuSE 11.2

On a MySql innodb Database with relations i tried

DbMetal.exe /provider:MySql /conn "[...]" /code:db.cs /case leave /namespace 
AttachedDb

Errormessage from DbMetal is:

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
<<< writing C# classes in file 'proxydb.cs'
DbMetal: Element type System.CodeDom.CodeDefaultValueExpression is not 
supported.
Parameter name: e 

In the generated Source file, there is an unexpected end after this:

        #region Parents
        [Association(Storage="_referrerIduSer", OtherKey="idUser", ThisKey="ReferrerID", Name="fk_User_User", IsForeignKey=true)]
        [DebuggerNonUserCode()]
        public User ReferrerIDUser
        {
            get
            {
                return this._referrerIduSer.Entity;
            }
            set
            {
                if (((this._referrerIduSer.Entity == value) == false))
                {
                    if ((this._referrerIduSer.Entity != null))
                    {
                        User previousUser = this._referrerIduSer.Entity;
                        this._referrerIduSer.Entity = null;
                        previousUser.idUserUser.Remove(this);
                    }
                    this._referrerIduSer.Entity = value;
                    if ((value != null))
                    {
                        value.idUserUser.Add(this);
                        _referrerID = value.idUser;
                    }
                    else
                    {
                        _referrerID = 

referrerID is a part of a innodb relation

Original issue reported on code.google.com by nilshueg...@googlemail.com on 9 Jun 2010 at 5:40

GoogleCodeExporter commented 9 years ago
Hi all! I got same error on simple sqlite table:

CREATE TABLE "users" ("user_id" INTEGER PRIMARY KEY  AUTOINCREMENT  NOT NULL , 
"User_name" TEXT NOT NULL )
CREATE TABLE forum_themes(
theme_id INTEGER primary key autoincrement not null,
author INTEGER not null,
header text not null,
 FOREIGN KEY(author) REFERENCES users(user_id)
)

DBML file genetates fine:
kitt@kitt-dell:~/fox-dl/DbLinq-0.20.1$ mono DbMetal.exe --provider=Sqlite  
--dbml=dsm.dbml --code=dsm.cs --conn="Data 
Source=/home/kitt/Projects/test_mvc/test_mvc/dsm.sqlite" --language=C#2 
--pluralize
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 SQLite database
<<< Writing file 'dsm.dbml'

But genetarate code file i got an error:
kitt@kitt-dell:~/fox-dl/DbLinq-0.20.1$ mono DbMetal.exe --code=dsm.cs dsm.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 'dsm.dbml'
<<< writing C# classes in file 'dsm.cs'
DbMetal: Element type System.CodeDom.CodeDefaultValueExpression is not 
supported.
Parameter name: e

About me:
Linux kitt-dell 2.6.32-22-generic #36-Ubuntu SMP Thu Jun 3 22:02:19 UTC 2010 
i686 GNU/Linux

Mono JIT compiler version 2.6.4 (tarball Чтв Июн 10 02:01:43 VLAST 2010)
Copyright (C) 2002-2010 Novell, Inc and Contributors. www.mono-project.com
    TLS:           __thread
    GC:            Included Boehm (with typed GC and Parallel Mark)
    SIGSEGV:       altstack
    Notifications: epoll
    Architecture:  x86
    Disabled:      none

System.Data.SQLite, Version=1.0.66.0, Culture=neutral, 
PublicKeyToken=db937bc2d44ff139 (Managed only)

This error raise only if column create definition contains :"NOT NULL" or 
"DEFAULT" or both clause. I am understand it's not clritical, but i think it's 
better for perfomance reason check not null value on DB level.

Original comment by istillfi...@gmail.com on 13 Jun 2010 at 3:14

GoogleCodeExporter commented 9 years ago
Just little update for my prev post. 
This error raise only if column create definition contains :"NOT NULL" or 
"DEFAULT" or both clause in the FOREIGN KEY colums. In other case not null 
works properly, but DEFAULT clause not make any change to code generation.

Original comment by istillfi...@gmail.com on 15 Jun 2010 at 3:53

GoogleCodeExporter commented 9 years ago
Second update: i found my problem happens only on Linux\Mono. On Windows XP all 
work fine.

Original comment by istillfi...@gmail.com on 16 Jun 2010 at 2:15

GoogleCodeExporter commented 9 years ago
It's annoying! In some cases, foreign key's have to be "not null". Imaging a 
primary key containing more than one column - all of these have to be "not 
null" - if one is a foreign key ... BANG

What can I do?

Original comment by Beiri2...@gmail.com on 1 Aug 2010 at 11:38

GoogleCodeExporter commented 9 years ago
The bug isn't in DbLinq, the bug is in Mono, as shown from the message:

    System.CodeDom.CodeDefaultValueExpression is not supported

This bug was first fixed in Mono 2.6.7, while openSUSE 11.2 includes Mono 2.4 
(though you shouldn't use Mono 2.4 with DbLinq anyway, as it causes hundreds of 
unit tests to fail).

As a workaround, please use Mono >= 2.6.7 or pass "/language:obsolete-c#":

    DbMetal.exe /provider:MySql /conn "[...]" \
        "/language:obsolete-c#" \
        /code:db.cs /case leave /namespace AttachedDb

Using /language:obsolete-c# will avoid using the System.CodeDom-based output, 
though this also means you won't be able to get VB.NET output either (though I 
suspect nobody actually uses VB.NET anyway...).

Original comment by jonmpr...@gmail.com on 2 Aug 2010 at 8:21