开发者

Bug with the dmbl designer file under VS2008?

I had been struggling today with the linq2sql dbml design files. When I start out and place my tables on the designer everything is OK. Them I modify the namespaces and turn off the connection string properties for the data context. Then I want to create partial extensions of my linq entities. So I hit F7 on the files designer. At this point everything is cool too. Then when I change something with the DB's schema I go back and add another ta开发者_Go百科ble or delete and re-add an old one, the MyContext.dbml loses the MyContext.design file underneath it. The other 2 (the .cs and the .layout are still there). Naturally it breaks everything I need to start from scratch. Very annoying. Any ideas?


Ah! Yes! You're using VS2008, right?

This is a known bug, and it actually matters where your using directives are in your half of the partial class...

using Foo;
namespace Bar {
    // ...
}

is bad, and trashes the designer file...

namespace Bar {
    using Foo;
    // ...
}

is fine!

This only applies when you have SomeName.dbml and SomeName.cs, so another fix is to rename the file. This is fixed in VS2010. Crazy, huh?


You should keep your classes in separate file/files. C# compiler doesn't care where parts are so this is a simple workaround.

Besides if you wrote your classes to the generated file(it isn't very clear in your post) then this is not a bug, but a desired behaviour.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜