none
EntityFramework Migrations Alpha 2

    Question

  • I am getting this error when trying to 'Update-Database' or 'AddMigration':

     

    The type initializer for 'System.Data.Entity.Migrations.DbMigrator' threw an exception

    Any ideas?


    • Edited by Sam Striano Monday, September 12, 2011 7:51 PM
    Monday, September 12, 2011 7:51 PM

Answers

  • Hi All,

    We have released an updated NuGet package that fixes the bugs that were causing this issue:

    Note: If you have received the following error when trying to use Code First Migrations Alpha 2 it is most likely due to bugs that were causing a dependency on SQL Compact and a dependency on a local SQL Express instance. We have released an updated package that resolves both these issues, please ensure you have updated the EntityFramework.Migrations package to version 0.6.2. You will need to close and re-open Visual Studio after updating the package, failure to do so will result in an error stating that “The project 'Demo' does not contain any migration contexts”. If you continue to get errors after updating to the latest package and re-starting Visual Studio then please start a thread in our Pre-Release Forum.

    Add-Migration : Exception has been thrown by the target of an invocation. 
    At line:1 char:14 
    + Add-Migration <<<< Init2 
    + CategoryInfo : NotSpecified: (:) [Add-Migration], TargetInvocationException 
    + FullyQualifiedErrorId : System.Reflection.TargetInvocationException,System.Data.Entity.Migrations.AddMigrationCommand

     

    ~Rowan

    Tuesday, September 13, 2011 3:53 PM
    Moderator

All replies

  • Sam and I have discussed this offline. Updating for the benefit of anyone else reading this thread...

    This is due to the following bugs (pasted from Alpha 2 post):

    Note: If you have received the following error when trying to use Code First Migrations Alpha 2 it is due to bugs that are causing a dependency on SQL Compact and a dependency on a local SQL Express instance (described in the Known Issues section of the release post). We have updated the NuGet package to chain in the SqlServerCompact package, please update the EntityFramework.Migrations package to version is 0.6.1.0. You will also need to install install SQL Express or setup a SQL Server Alias that redirects .\SQLEXPRESS to another SQL Server (Name: .\SQLEXPRESS, Port: 1433, Protocol: TCP/IP, Server: <SQL Server instance you are targeting>). These bugs will be fixed in the next preview, coming soon.

    Add-Migration : Exception has been thrown by the target of an invocation. 
    At line:1 char:14 
    + Add-Migration <<<< Init2 
    + CategoryInfo : NotSpecified: (:) [Add-Migration], TargetInvocationException 
    + FullyQualifiedErrorId : System.Reflection.TargetInvocationException,System.Data.Entity.Migrations.AddMigrationCommand

     

    It seems that a SQL Server Alias will solve the issue if you are using Windows Authentication but not SQL Authentication. We have an updated build that fixes both these issue and are running some checks etc. before making it available on NuGet.

    ~Rowan

    Monday, September 12, 2011 10:28 PM
    Moderator
  • Hi All,

    We have released an updated NuGet package that fixes the bugs that were causing this issue:

    Note: If you have received the following error when trying to use Code First Migrations Alpha 2 it is most likely due to bugs that were causing a dependency on SQL Compact and a dependency on a local SQL Express instance. We have released an updated package that resolves both these issues, please ensure you have updated the EntityFramework.Migrations package to version 0.6.2. You will need to close and re-open Visual Studio after updating the package, failure to do so will result in an error stating that “The project 'Demo' does not contain any migration contexts”. If you continue to get errors after updating to the latest package and re-starting Visual Studio then please start a thread in our Pre-Release Forum.

    Add-Migration : Exception has been thrown by the target of an invocation. 
    At line:1 char:14 
    + Add-Migration <<<< Init2 
    + CategoryInfo : NotSpecified: (:) [Add-Migration], TargetInvocationException 
    + FullyQualifiedErrorId : System.Reflection.TargetInvocationException,System.Data.Entity.Migrations.AddMigrationCommand

     

    ~Rowan

    Tuesday, September 13, 2011 3:53 PM
    Moderator