Ronald Wildenberg
Ronald Wildenberg

Reputation: 32094

Weird mapping error in linq-to-sql dbml file in VS2010

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.

Upvotes: 1

Views: 1072

Answers (1)

Oleks
Oleks

Reputation: 32323

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.

Upvotes: 7

Related Questions