Enable-Migrations throws confusing exception on Web Site projects


Repro is to install EF on a Web Site project, create a Code First model, and then run the Enable-Migrations command.

Ideally we could support Web Sites projects but Web Site projects are quite different from regular projects and we would probably need to re-do how we interact with EnvDTE, then test it, stabilize it, etc. We haven't seen significant demand of Web Site support, and I believe we already decided not to fix a previous bug for this.

This bug is then about detecting that we are in a Web Site project and throw a clearer exception.

The exception right now looks like this:

System.ArgumentException: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))

Server stack trace:
at EnvDTE.Properties.Item(Object index)
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)

Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at EnvDTE.Properties.Item(Object index)
at System.Data.Entity.Migrations.Extensions.ProjectExtensions.GetPropertyValue[T](Project project, String propertyName)
at System.Data.Entity.Migrations.MigrationsDomainCommand.GetFacade(String configurationTypeName)
at System.Data.Entity.Migrations.EnableMigrationsCommand.FindContextToEnable(String contextTypeName)
at System.Data.Entity.Migrations.EnableMigrationsCommand.<>c__DisplayClass2.<.ctor>b__0()
at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command)
The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
Closed Sep 19, 2013 at 10:33 PM by RoMiller
Web sites are not a key scenario.


RoMiller wrote Oct 9, 2012 at 5:26 PM

We should include information in the exception that you can put migrations into a class library.

chipsnpieces wrote Dec 3, 2015 at 12:29 PM

Dear RoMiller, can you please share an example/sample of how to put migrations into a class library to Enable-Migrations in Web Site in Webforms.