views:

179

answers:

1

Since I switched to VS2010, several times a day I get a compilation error in my dbml file:

DBML1005: Mapping between DbType 'bigint' and Type
'MyNamespace.SecurityToken' in Column 'SecurityToken' of Type
'Employee' is not supported

When I restart VS2010 the error disappears. I have no problems running my application using this dbml file (specifically, there are no problems getting correct values inside the SecurityToken property of Employee objects).

The SecurityToken property is of an enum type defined as follows:

[Flags]
public enum SecurityToken : long
{
    None = 1,
    Admin = 2,
    ......
}

The SecurityToken column in the database is of type bigint.

Am I missing something? It's especially weird that the error only happens sometimes, when I'm writing code that isn't related at all to the LINQ model.

+5  A: 

It seems this is a LINQ bug when resolving the enums. The workaround is to add the global:: prefix.

A necessary mapping for this in your DBML file may look like:

<Column Name="SecurityToken" Type="global::MyNamespace.SecurityToken" 
        DbType="BigInt NOT NULL" CanBeNull="false" />

Of cause, you could do the same using designer.

Alex
Alternatively, declare the enum in the same namespace as the DataContext. IIRC, this 'bug' was present in VS2008 too.
leppie
@leppie: it's interesting sometimes mapping works fine without using the global keyword but sometimes...
Alex
I'll try it and report back if the problem no longer occurs. Thanks.
Ronald Wildenberg