Visual Studio 2008 数据库项目中更智能的上下文菜单
我正在使用 SQL Server 2008 数据库项目,我发现添加某些项目非常麻烦。例如,如果我右键单击 Tables =>键并导航到“添加”项,我希望看到可以添加的不同类型的键。相反,我看到了不适用的库存项目,并且我被迫导航“添加新项目”屏幕以查找主键。
有没有办法提高效率?我有Resharper;我可以以某种方式利用模板吗(对这些有点菜鸟)。谢谢!
I'm using a SQL Server 2008 Database Project, and I'm finding it's very cumbersome to add certain items. For example, if I right click on Tables => Keys and navigate to the Add item, I'd expect to see the different kinds of keys that I can add. Instead, I see the stock items that don't apply, and I'm forced to navigate the Add New Item screen to find Primary Key.
Is there a way to make this more efficient? I have Resharper; can I leverage templates somehow (kind of a noob with these). Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
升级到 VS 2010 将解决您的问题。从新的上下文菜单中选择“表...”:
会产生以下选择,这些选择比2008 版本:
Upgrading to VS 2010 will solve your problem. Selecting Table... from the new context menu:
yields the following selections, which are much more helpful than the 2008 versions:
这里有一个建议:
创建一个数据库项模板。将其存储在 Program Files 中 VS 文件夹的 Database Project Items 子文件夹中。
创建一个宏,从该模板创建一个项目。您可以首先记录自己添加一个项目,然后修改生成的宏。
使用“工具/自定义”菜单的“工具栏”选项卡,单击左侧列表框中“上下文菜单”选项旁边的复选框。这将使上下文菜单出现在菜单栏中。找到你想要的那个。根据您的说法,这可能是“其他上下文菜单/数据库项目文件夹”。
仍在“工具/自定义”菜单上,切换到“命令”选项卡。单击左侧列表框中的宏条目。您的宏应该出现在该列表框中的某个位置。
将宏条目拖到菜单栏中现在显示的上下文菜单下拉菜单上。当您悬停时它们会打开。将条目拖放到您想要增强的菜单上。
您可能想要更改新菜单选项的名称。您可以通过从上下文菜单工具栏返回该菜单来执行此操作,直到到达新的菜单选项。右键单击它,您将能够重命名它或为其分配一个图标。
关闭工具/自定义菜单。现在,您的上下文菜单上将有一个新的菜单选项!
现在,您录制的宏?您可能需要大量摆弄它才能使其在新环境中正常工作。宏编程(以及 VS 可扩展性)就是这样。
如果您想让菜单上下文相关,以便仅在某些条件成立时才显示某些内容(例如您单击的文件夹被命名为“Tables”),您可能需要编写一个加载项。这可能既有趣又浪费时间,但最终您将更多地了解 VS 的工作原理,并使您的菜单完全按照您想要的方式运行。
Here's a suggestion:
Create a database item template. Store it in the Database Project Items subfolder of the VS folder in Program Files.
Create a macro that creates an item from that template. You can start by recording yourself adding an item, and modify the resulting macro.
Using the Tools/Customize menu, Toolbars tab, click the checkbox by the Context menu option in the left-hand list box. This will make the context menus appear in the menu bar. Locate the one you want. From what you've said this will probably be Other Context Menus/DB Project Folder.
Still on the Tools/Customize menu, switch to the Commands tab. Click on the Macros entry in the left-hand list box. Your macro should appear somewhere in that listbox.
Drag the entry for your macro onto the Context Menu drop-down menus that now appear in your menu bar. They will open up as you hover. Drop the entry onto the menu you want to enhance.
You will probably want to change the name of your new menu option. You can do this by going back to that menu from the Context Menus toolbar, until you reach your new menu option. Right click on it and you will be able to rename it or assign it an icon.
Close the Tools/Customize menu. You will now have a new menu option on your context menu!
Now, the macro you recorded? You'll probably have to fiddle with it A LOT to get it to work properly from its new context. Macro programming (and VS extensibility) is like that.
If you want to make your menus context-sensitive, so that certain content only appears when certain conditions are true (like the folder you're clicking on being named "Tables") you will probably need to write an add-in. This can be both fun and a time sink, but in the end you'll know a lot more about how VS works and have your menus behaving exactly as you want.