Bug #71427 Cannot create a new model with EF6 and VS 2013
Submitted: 20 Jan 2014 15:23 Modified: 27 Feb 2014 23:30
Reporter: Gabriela Martinez Sanchez Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Visual Studio Integration Severity:S2 (Serious)
Version:1.1.3 OS:Any
Assigned to: Gabriela Martinez Sanchez CPU Architecture:Any
Tags: t1.1.3

[20 Jan 2014 15:23] Gabriela Martinez Sanchez
Description:
Cannot create a new model when using VS 2013 and EF 6. After installing Connector/Net 6.8.3 and MySQL for Visual Studio 1.1.3

How to repeat:
Install VS 2013
Install MySQL for VS 1.1.3 plugin for Visual Studio 2013
Install Connector/Net 6.8.3
Create a new console application for .net 4.5
Add to this application the Entity Framework 6 package
   PM Install-package EntityFramework
Copy the MySql.Data.Entity.EF6.dll to the bin folder of the new application
Add the provider to the app.config file 
<provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6"></provider>
Compile the project
Add a new Empty Model
Create a  new entity on the new model with three columns: Id int, Name string, LastUpdated DateTime
Select the MySQL template on the properties of the  model
Do Generate Database from Model

Expected results 
  A new MySQL script is showed.
Actual results

A Null reference exception is shown with the following message:
Encountered the following errors while processing the template 'C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\Microsoft\Entity Framework Tools\DBGen\SSDLToMySQL.tt: 
Line 92, Column 0: 'Running transformation: System.NullReferenceException: Object reference not set to an instance of an object. 
at Microsoft.Data.Entity.Design.DatabaseGeneration.MetadataWorkspaceExtensions.GetAllAssociationSets(ItemCollection itemCollection) 
at Microsoft.VisualStudio.TextTemplating9770EDB7EEA4FAB212FD47C3C49157478918437E5C24BA0C88699C9856FBEAA2348AB189A2E6944E18AC69C509CF8190B80D2774D9B698B84EAF7A310720C20A.GeneratedTextTransformation.TransformText() in c:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\Microsoft\Entity Framework Tools\DBGen\SSDLToMySQL.tt:line 93' 

Suggested fix:
N/A
[20 Jan 2014 15:45] Gabriela Martinez Sanchez
Additionally there's a workaround:

On the machine where VS 2013 is installed, VS plugin (1.1.3 GA) and Connector/Net please do the following: 

Note: close all VS instances before doing the steps. 

On a Windows Explorer window go to this path or wherever the Connector/Net binaries were installed to. By default this is the location:

C:\Program Files (x86)\MySQL\MySQL Connector Net 6.8.3\Assemblies\v4.5\ 

Copy the file: 

MySql.Data.Entity.EF6.dll 

And paste it to this folder 

C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\PrivateAssemblies 

If it asks to overwrite it please do so. 

In order to copy the file administrator rights are necessary.

Then you can try again to generate the script for your model. It should work fine. 

It is important to have the 1.1.3 version of the VS plugin installed since this workaround is for that. The download link is at:
http://dev.mysql.com/downloads/windows/installer/
[20 Jan 2014 15:54] Gabriela Martinez Sanchez
Posted by developer:
 
We need to update the reference to the latest version of Connector/Net. Currenntly we're including Connector/Net 6.8.1.
[22 Jan 2014 1:49] Gabriela Martinez Sanchez
Posted by developer:
 
A patch for this bug has been committed for the following branch: 1.1, trunk.
[22 Jan 2014 1:51] Gabriela Martinez Sanchez
A fix for this bug has been committed to be released on the next 1.1.4 version.
[27 Feb 2014 23:30] Daniel So
Added the following entry into the MySQL for Visual Studio 1.1.4 changelog:

"A new model could not be created with Entity Framework 6 in Visual Studio 2013 when using MySQL for Visual Studio 1.1.3 and Connector/Net 6.8.3."
[25 Jun 2014 16:47] Ido Flaishon
This happened to me as well, and the workaround worked. based on 6.9.1 MySql connector, EF6, and VS 2013
[10 Jun 2015 10:38] Rasmus Iversen
Still getting this error with VS 2013 EF 6 Connector/NET 6.9 MySQL for VS 1.2
[12 Jul 2015 16:57] Michael Cress
I am also seeing this bug. I have installed the EF6 references via NuGet and it is reproducible on two separate development machines. Gabriela's work-around is not working for me. Can this issue be reopened?
[4 Oct 2015 19:49] Piotr Purta
Same (or similar) bug: 

Encountered the following errors while processing the template 
Entity Framework Tools\DBGen\SSDLToMySQL.tt: 

Line 1, Column 0: 'Running transformation: System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.Data.Entity.Design.DatabaseGeneration.MetadataWorkspaceExtensions.GetAllAssociationSets(ItemCollection itemCollection)
   at
Entity Framework Tools\DBGen\SSDLToMySQL.tt:line 2

I am using:
Visual Studio 2015
MySQL for Visual Studio 1.2.4
Connector/NET 6.9.7

Provided solution does not working.