9
votes

I can't seem to get Entity Framework 6.0.1 to install on a couple of F# projects I have. This is the error message I'm getting:

Executing script file 'C:\source\payboard\PayboardWeb\packages\EntityFramework.6.0.1\tools\install.ps1'. Exception calling "SetData" with "2" argument(s): "Type 'Microsoft.VisualStudio.FSharp.ProjectSystem.Automation.OAProject' in assembly 'FSharp.ProjectSystem.Base, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' is not marked as serializable." At C:\source\payboard\PayboardWeb\packages\EntityFramework.6.0.1\tools\EntityFramework.psm1:633 char:5 + $domain.SetData('project', $Project) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : SerializationException

System.NullReferenceException: Object reference not set to an instance of an object. at System.Data.Entity.ConnectionFactoryConfig.InitializeEntityFrameworkCommand.Execute() at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command)

It seems like there's an open bug for it on the EF6 forums (https://entityframework.codeplex.com/workitem/891), but it hasn't gotten any love, so far as I can tell.

EF6 installs just fine on non-F# projects.

Any suggested workarounds?

1
I think you are pretty much out of luck until MS changes the 'Microsoft.VisualStudio.FSharp.ProjectSystem.Automation.OAProject' type to be serializable. You could always submit this issue on the User Voice site for F# to see if that gets more love. I doubt the EF team will be able to fix something in the base language. - Scott Wylie
If you read down in the comments of the following post from the EF team, someone from the team somewhat answers your question of when will EF support F#. Not sure if it helps but it is at least official acknowledgement. blogs.msdn.com/b/adonet/archive/2013/10/31/… - Scott Wylie
I dug through @ScottWylie's link and found work item 891 mentioned. It appears that F# may work in the next version of EF. - Dan Lyons

1 Answers

5
votes

This is getting unblocked in EF6.1. Here is the workitem.

Note that the issue here is not EF itself but how the package is being added to your project. This makes me think that until EF6.1 is released you could probably work around this issue by getting the package unzipping it and adding references to EF6 assemblies manually to your project. Then you would have to update your config accordingly. (You could also create a temp C# project add the EF6 NuGet package which will give you the EntityFramework and EntityFramework.SqlServer dlls you could copy to your F# project and also a config file you could copy from which will be much easier than coming with the right configuration on your own)