Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set StartUp Project parameter for Entity Framework migrations

When using EF 4.3.1 migrations every time i need to add a migration or update database i have to use the StartUpProject parameter. Can I set this somewhere so I don't have to keep doing this? I don't want to set my data project as the start up project. My context and migrations are in different projects if that makes a difference.

Exception thrown when not using StartpProject parameter:

update-database -verbose
Using NuGet project 'Data.Deployment'.
Using StartUp project ''.
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentException: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
   --- End of inner exception stack trace ---
   at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters)
   at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
   at System.Management.Automation.ComMethod.InvokeMethod(PSMethod method, Object[] arguments)
Exception has been thrown by the target of an invocation.
like image 703
newbie_86 Avatar asked Aug 23 '12 10:08

newbie_86


1 Answers

Use the StartupProject parameter: Update-database -StartupProject "PROJECTNAME"

like image 93
Mike Bovenlander Avatar answered Oct 26 '22 09:10

Mike Bovenlander