views:

26

answers:

2

In my persistence layer, I've declared a load of Enums to represent tables containing reference data (i.e. data never changes).

In Linq2SQL, I am able to set the type of an entity property to an enum type and all is well, but as soon as I set a second entity's property to use the same enum type, the Code Generator (MSLinqToSQLGenerator) start generating an empty code file.

I assume that MSLinqToSQLGenerator is quietly crashing. The question is why, and are there any work-arounds? Anyone else experienced this problem?

A: 

Oddly, I've discovered that this behavior only occured with an Enum named "GrantType". As soon as changed the name of the enum, the generator started working again.

Mark
+2  A: 

Is your enum by any chance in a file named the same as the dbml? There is a bug in 3.5 (fixed in 4.0) where conflicts cause an empty file. Oddly, usually moving the using directives (and right-click; run custom tool) fixes it.

So if you have "foo.dbml" and your own "foo.cs" (in the same folder) with:

using System;
namespace MyNamespace {

}

it will break (generate an empty foo.designer.cs). If you have:

namespace MyNamespace {
    using System;

}

it will work. I'm not kidding. Likewise, renaming "foo.cs" to "bar.cs" (and right-click, run custom tool) will fix it.

Marc Gravell