How to automate Entity Data Model Wizard in Visual Studio 2010 - visual-studio-2010

I can use the Package Manager Console to write some Powershell and automate Visual Studio. I can start the process of adding a Entity Framework Data Model with this code:
$dte.ItemOperations.AddNewItem("Visual C#\Data\ADO.NET Entity Data Model", "Foo.edmx")
I want to to automate the EDM wizard that pops up next so my Powershell script can handle all the steps of adding an EF model to my project. How to I reference this Entity Data Model Wizard in code?
When I manually do this with the macro recorder in Visual Studio running, it will skip these wizard steps for the Entity Data Model Wizard. I was hoping that could show me how to reference it in code.
I want a set of Powershell commands to automate all the wizard steps for adding an EF model to my project. As I understand it, a nuget package can setup all the necessary parts with Powershell and my package will need to configure an Entity Framework model on its own.

Instead of automating the EDM wizard in Powershell, I can use the EdmGen.exe command line utility to perform the task in Powershell.
EdmGen.exe is documented here: http://msdn.microsoft.com/en-us/library/bb738546.aspx

Related

Automate the renaming of classes in Visual Studio 2013 using the SDK and VS API

How do I rename classes with an API call, from within a Visual Studio 2013 plugin we are building?
We are already adding files and generating code to a project from within the plugin, but how to can we open the rename refactoring dialogue?
The plugin is an entity editor for a custom ORM system. Here is a screenshot
You can execute any command such as "Refactor.Rename", etc. using either DTE.ExecuteCommand("mycommand") or by command guid and id:
HOWTO: Execute a command by Guid and Id from a Visual Studio package.
http://www.visualstudioextensibility.com/articles/packages/
To learn the command names go to "Tools" > "Customize..." and then "Keyboard" button.

Storing user preferences for a Visual Studio custom project wizard

Background:
I am working on a SDK that allows its users to create custom plugins for an existing product. There is a bit of boilerplate code/file copy/COM DLL registration required for the plugin integration.To ease things for the plugin developer, I have written a Visual Studio custom project template that uses a IWizard to create a new solution, add couple of projects, generate a number of files containing the boilerplate code as well as some batch files that get executed as a post build event.
The wizard has a number of fields (such as the copyright header that needs to be inserted at the top of each generated file) that the user can edit to customize the generated code.
The Question
I'd like to persist some of the customizations and use it across multiple runs of the wizard. I also know the usual recommended places for individual applications to store their settings is under %APPDATA%. I'd like to know if there are any other places where specifically Visual Studio extensions can store their settings or I should just treat this as an standalone application and go with the %APPDATA% folder. The reason I ask is further down the line, I like to allow the plugin developers to share these settings via VS->Tools->Import & Export Settings
You have two options. You can use Visual Studio's DialogPage which will show up your configurations in Visual Studio's Options window. You can also use IProfileManager, if you do not want your preferences to show in Options window but you still want to persist them.
I have written blog post about both of these options. These posts contains complete details and code snippets.
Integration with Visual Studio Options Window using custom controls
Persisting settings without using Options dialog in Visual Studio

Import all objects from Oracle to Visual Studio Database Project

I have a Oracle database to which I connect from Visual Studio 2010 (Oracle Developer Tools). I now have the database in the "Server Explorer" window and can see all Tables, Views, Functions, etc.
Now I want to have all those objects in my database project solution (I want to use the version control of TFS, that's the reason I want all objects in my solution). I can right click a single function and choose "Generate Create Script to Project", then it will do exactly what I want, it creates a new script in the "Functions" folder of the database project, with the same name as the function.
Problem:
If I select two or more functions and use the "Generate Create Script to Project" function, then I have to choose a name for the script and it will write all the functions in one script. But I want a single file per script.
Question:
Is it somehow possible to export all objects from the oracle database and import them as script in the Visual Studio database project?
If I use a different driver (devart), then I am able to do it, but we want to use the ODT and I couldn't find an easy way to complete that task there.
Edit: Just noticed, that the devart project is not compatible with source control, so we absolutely have to go with ODT.

Accessing Visual Studio Database Project Schema Programatically

I'm trying to find a way to access the schema of a database project programatically from within Visual Studio 2010.
For example, if I have a solution containing a SQL Server Database Project which defines tables, views etc, and Visual Studio displays those objects within the schema view, I'd like to be able to enumerate the objects in the schema view.
Can anyone provide some tips or a link? Thanks.
Here is a starting point on MSDN. The "Create Custom Features for Database Projects" part is probably relevant for you.

How to add optional-components to Visual Studio Setup and Deployment projects?

I'm trying to create a very basic "Setup and Deployment" project using Visual Studio.
What I would like is the ability to choose which components to install. Let's say that each component consists in the primary output of a single class library (i.e. each component is actually a single module or compiled assembly).
I haven't seen such an option in the standard set of available dialogs. But I have seen that with a little effort we can somehow create custom dialogs.
How can I programmatically detect which component are available as part of the setup and deployment project? (i.e. I would like the project to work even when adding or removing a component from the installation)
How do I extend or create a custom dialog that displays the list of available components?
How do I detect which components the end-user has choosen to install?
I'm somewhat familiar with Orca, the tool to manipulate .msi files as well as full blown installer applications like InstallShield, but I would like to make this using only raw Visual Studio and other available open-source tools.
Thanks for your help.
VDP (Visual studio Deployment Project) is not cut out for this kind of stuff (read: use Wix instead):
(I'm guessing you want this at runtime) You can use MsiQueryComponentState but for that you will need to pass the component GUID which in VDP you don't have control over.
This comes out of the box with everything other then VDP.
(I'm guessing you want this at setup time...) You can use Condition in order to execute custom action based upon Component Install State, in VDP you don't have control over the component id (not to be confused with the component guid) which is needed in order to preform component condition.

Resources