VS2010 opens my class-file (.cs) in the designer mode VS2010 opens my class-file (.cs) in the designer mode xml xml

VS2010 opens my class-file (.cs) in the designer mode


As described in an answer to this question you can do this:

[System.ComponentModel.DesignerCategory("Code")]class FakeDbConnection: DbConnection { ... }

Important: The attribute needs to be fully qualified otherwise VS2010 will ignore this.

Important (thanks to jmbpiano): The attribute only applies to the first class in the file.


The inheritance hierarchy indicates that this class (DbConnection) inherits from System.ComponentModel.Component. Try right click the file and View Source instead.

As always you can check MSDN! Here is the documentation for DbConnection.


Thats because DBConnection inherits "Component".About disabling VS to add "Subtype" in csproj-file - I don't think thats possible.

You can still aceess the code, by right-clicking in designer -> show code (I think "F7" is the shortcut key for that)