MappingSource could not be found

205 views
Skip to first unread message

Matthijs de Z

unread,
Jan 27, 2010, 5:14:39 AM1/27/10
to DbLinq
Hi,

In mysql I created a DB called 'dblinqtest' with a table 'table1'
created with the following structure (it was just for a test):

CREATE TABLE `table1` (
`name` varchar(30) COLLATE latin1_general_ci NOT
NULL,
`city` varchar(30) COLLATE latin1_general_ci NOT
NULL,
`phonenumber` varchar(30) COLLATE latin1_general_ci NOT
NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
COLLATE=latin1_general_ci


I used dbmetal 0.19.0.0 with this batch to create a c# class:

DbMetal.exe --provider=MySql --database:dblinqtest --server=127.0.0.1
--user=root --password:1matthijs2 --namespace=dblinqtestNS --
code=dblinqclass.cs --sprocs

after that, I created a new c# program added DbLinq, DbLinq.MySql and
MySql.Data to the references and added dblinqclass.cs to the project.

The main form is just empty and I tried to compile.
Unfortunately I got some errors.

"Error 1 The type or namespace name 'MappingSource' could not be found
(are you missing a using directive or an assembly reference?) C:
\Documents and Settings\matthijs\My Documents\Visual Studio
2008\Projects\dblinq tests\projects
\dblinqtest1\dblinqtest1\dblinqclass.cs 52 40 dblinqtest1
"

and

"Error 3 The type or namespace name 'IVendor' could not be found (are
you missing a using directive or an assembly reference?) C:\Documents
and Settings\matthijs\My Documents\Visual Studio 2008\Projects\dblinq
tests\projects\dblinqtest1\dblinqtest1\dblinqclass.cs 65 47
dblinqtest1
"

"Error 7 The type or namespace name 'TableAttribute' could not be
found (are you missing a using directive or an assembly reference?) C:
\Documents and Settings\matthijs\My Documents\Visual Studio
2008\Projects\dblinq tests\projects
\dblinqtest1\dblinqtest1\dblinqclass.cs 84 3 dblinqtest1
"

"Error 8 The type or namespace name 'Column' could not be found (are
you missing a using directive or an assembly reference?) C:\Documents
and Settings\matthijs\My Documents\Visual Studio 2008\Projects\dblinq
tests\projects\dblinqtest1\dblinqtest1\dblinqclass.cs 132 4
dblinqtest1
"

"Error 9 The type or namespace name 'ColumnAttribute' could not be
found (are you missing a using directive or an assembly reference?) C:
\Documents and Settings\matthijs\My Documents\Visual Studio
2008\Projects\dblinq tests\projects
\dblinqtest1\dblinqtest1\dblinqclass.cs 132 4 dblinqtest1
"

etc...etc...

Am I missing a reference? Or do I need to do something else. I googled
around and cannot find what the problem is. Maybe you know?

Kind regards,

Matthijs

the class file created by dbmetal
-----------------------------------------------
#region Auto-generated classes for dblinqtest database on 2010-01-27
10:20:07Z

//
// ____ _ __ __ _ _
// | _ \| |__ | \/ | ___| |_ __ _| |
// | | | | '_ \| |\/| |/ _ \ __/ _` | |
// | |_| | |_) | | | | __/ || (_| | |
// |____/|_.__/|_| |_|\___|\__\__,_|_|
//
// Auto-generated from dblinqtest on 2010-01-27 10:20:07Z
// Please visit http://linq.to/db for more information

#endregion

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Text;
using DbLinq.Data.Linq;
using DbLinq.Data.Linq.Mapping;

namespace dblinqtestNS
{
public partial class DbLinqTest : DataContext
{
#region Extensibility Method Definitions

partial void OnCreated();

#endregion

public DbLinqTest(string connectionString)
: base(connectionString)
{
OnCreated();
}

public DbLinqTest(IDbConnection connection)
#if MONO_STRICT
: base(connection)
#else // MONO_STRICT
: base(connection, new DbLinq.MySql.MySqlVendor())
#endif // MONO_STRICT
{
OnCreated();
}

public DbLinqTest(string connection, MappingSource mappingSource)
: base(connection, mappingSource)
{
OnCreated();
}

public DbLinqTest(IDbConnection connection, MappingSource
mappingSource)
: base(connection, mappingSource)
{
OnCreated();
}

#if !MONO_STRICT
public DbLinqTest(IDbConnection connection, IVendor vendor)
: base(connection, vendor)
{
OnCreated();
}
#endif // !MONO_STRICT

#if !MONO_STRICT
public DbLinqTest(IDbConnection connection, MappingSource
mappingSource, IVendor vendor)
: base(connection, mappingSource, vendor)
{
OnCreated();
}
#endif // !MONO_STRICT

public Table<Table1> Table1 { get { return GetTable<Table1>(); } }

}

[Table(Name = "dblinqtest.table1")]
public partial class Table1 : INotifyPropertyChanging,
INotifyPropertyChanged
{
#region INotifyPropertyChanging handling

public event PropertyChangingEventHandler PropertyChanging;

private static PropertyChangingEventArgs emptyChangingEventArgs =
new PropertyChangingEventArgs("");
protected virtual void SendPropertyChanging()
{
if (PropertyChanging != null)
{
PropertyChanging(this, emptyChangingEventArgs);
}
}

#endregion

#region INotifyPropertyChanged handling

public event PropertyChangedEventHandler PropertyChanged;

protected virtual void SendPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}

#endregion

#region Extensibility Method Definitions

partial void OnCreated();
partial void OnCityChanged();
partial void OnCityChanging(string value);
partial void OnNameChanged();
partial void OnNameChanging(string value);
partial void OnPhoneNumberChanged();
partial void OnPhoneNumberChanging(string value);

#endregion

#region string City

private string _city;
[DebuggerNonUserCode]
[Column(Storage = "_city", Name = "city", DbType = "varchar(30)",
AutoSync = AutoSync.Never, CanBeNull = false)]
public string City
{
get
{
return _city;
}
set
{
if (value != _city)
{
OnCityChanging(value);
SendPropertyChanging();
_city = value;
SendPropertyChanged("City");
OnCityChanged();
}
}
}

#endregion

#region string Name

private string _name;
[DebuggerNonUserCode]
[Column(Storage = "_name", Name = "name", DbType = "varchar(30)",
AutoSync = AutoSync.Never, CanBeNull = false)]
public string Name
{
get
{
return _name;
}
set
{
if (value != _name)
{
OnNameChanging(value);
SendPropertyChanging();
_name = value;
SendPropertyChanged("Name");
OnNameChanged();
}
}
}

#endregion

#region string PhoneNumber

private string _phoneNumber;
[DebuggerNonUserCode]
[Column(Storage = "_phoneNumber", Name = "phonenumber", DbType =
"varchar(30)", AutoSync = AutoSync.Never, CanBeNull = false)]
public string PhoneNumber
{
get
{
return _phoneNumber;
}
set
{
if (value != _phoneNumber)
{
OnPhoneNumberChanging(value);
SendPropertyChanging();
_phoneNumber = value;
SendPropertyChanged("PhoneNumber");
OnPhoneNumberChanged();
}
}
}

#endregion

#region ctor

public Table1()
{
OnCreated();
}

#endregion

}
}

Jonathan Pryor

unread,
Feb 1, 2010, 2:53:18 PM2/1/10
to dbl...@googlegroups.com
On Wed, 2010-01-27 at 02:14 -0800, Matthijs de Z wrote:
> after that, I created a new c# program added DbLinq, DbLinq.MySql and
> MySql.Data to the references and added dblinqclass.cs to the project.
> Unfortunately I got some errors.
>
> "Error 1 The type or namespace name 'MappingSource' could not be found
> (are you missing a using directive or an assembly reference?) C:
> \Documents and Settings\matthijs\My Documents\Visual Studio
> 2008\Projects\dblinq tests\projects
> \dblinqtest1\dblinqtest1\dblinqclass.cs 52 40 dblinqtest1
> "

You need to add a reference to System.Data.Linq.dll (included in .NET
3.5 and/or VS 2008).

> and
>
> "Error 3 The type or namespace name 'IVendor' could not be found (are
> you missing a using directive or an assembly reference?) C:\Documents
> and Settings\matthijs\My Documents\Visual Studio 2008\Projects\dblinq
> tests\projects\dblinqtest1\dblinqtest1\dblinqclass.cs 65 47
> dblinqtest1
> "

Odd; Very, very odd.

Your source code is missing a 'using DbLinq.Vendor;' declaration.

However, I don't know *why* you're missing that. Your attached file
clearly shows the presence of '#if MONO_STRICT' blocks, but it's lacking
one in the toplevel section; see e.g.

http://dblinq2007.googlecode.com/svn/trunk/tests/Northwind.Expected.Sqlite-DbMetal.cs

Where there is:

#if MONO_STRICT
using System.Data.Linq;
#else // MONO_STRICT
using DbLinq.Data.Linq;
using DbLinq.Vendor;
#endif // MONO_STRICT

Your file is missing this, and I don't know why. :-/

Creating entities for a local SQL Server instance results in the
expected MONO_STRICT blocks, and afaik this isn't vendor-specific, so
you should have them (yet curiously do not).

Did you manually edit the file?

> "Error 7 The type or namespace name 'TableAttribute' could not be
> found (are you missing a using directive or an assembly reference?) C:
> \Documents and Settings\matthijs\My Documents\Visual Studio
> 2008\Projects\dblinq tests\projects
> \dblinqtest1\dblinqtest1\dblinqclass.cs 84 3 dblinqtest1
> "

TableAttribute is in System.Data.Linq.dll.

> "Error 8 The type or namespace name 'Column' could not be found (are
> you missing a using directive or an assembly reference?) C:\Documents
> and Settings\matthijs\My Documents\Visual Studio 2008\Projects\dblinq
> tests\projects\dblinqtest1\dblinqtest1\dblinqclass.cs 132 4
> dblinqtest1
> "

Ditto.

> "Error 9 The type or namespace name 'ColumnAttribute' could not be
> found (are you missing a using directive or an assembly reference?) C:
> \Documents and Settings\matthijs\My Documents\Visual Studio
> 2008\Projects\dblinq tests\projects
> \dblinqtest1\dblinqtest1\dblinqclass.cs 132 4 dblinqtest1
> "

Ditto.

> Am I missing a reference? Or do I need to do something else. I googled
> around and cannot find what the problem is. Maybe you know?

Yes, you're missing System.Data.Linq.dll. :-)

- Jon


Matthijs de Z

unread,
Feb 6, 2010, 7:13:32 AM2/6/10
to DbLinq
Hi Jon,

thanks for the answer. I'll give it another try this weekend with your
tips.
Regards,

Matthijs

P.S. nope...I did not alter the code manually

On 1 feb, 20:53, Jonathan Pryor <jonpr...@vt.edu> wrote:
> On Wed, 2010-01-27 at 02:14 -0800, Matthijs de Z wrote:
> > after that, I created a new c# program added DbLinq, DbLinq.MySql and
> > MySql.Data to the references and added dblinqclass.cs to the project.
> > Unfortunately I got some errors.
>
> > "Error        1       The type or namespace name 'MappingSource' could not be found
> > (are you missing a using directive or an assembly reference?)      C:
> > \Documents and Settings\matthijs\My Documents\Visual Studio
> > 2008\Projects\dblinq tests\projects
> > \dblinqtest1\dblinqtest1\dblinqclass.cs    52      40      dblinqtest1
> > "
>
> You need to add a reference to System.Data.Linq.dll (included in .NET
> 3.5 and/or VS 2008).
>
> > and
>
> > "Error        3       The type or namespace name 'IVendor' could not be found (are
> > you missing a using directive or an assembly reference?)   C:\Documents
> > and Settings\matthijs\My Documents\Visual Studio 2008\Projects\dblinq
> > tests\projects\dblinqtest1\dblinqtest1\dblinqclass.cs      65      47
> > dblinqtest1
> > "
>
> Odd; Very, very odd.
>
> Your source code is missing a 'using DbLinq.Vendor;' declaration.
>
> However, I don't know *why* you're missing that.  Your attached file
> clearly shows the presence of '#if MONO_STRICT' blocks, but it's lacking
> one in the toplevel section; see e.g.
>

>        http://dblinq2007.googlecode.com/svn/trunk/tests/Northwind.Expected.S...

Matthijs de Z

unread,
Feb 8, 2010, 4:21:28 AM2/8/10
to DbLinq
Hi Jon,

after adjusting the code like you said, I don't have any errors
anymore. Thanks for helping out.
Regards,

Matthijs

Reply all
Reply to author
Forward
0 new messages