none
Error with Entity Framework RRS feed

  • Question

  • I am getting the following error when I try to run Enable Mirgrations

    System.Runtime.Serialization.SerializationException: Type is not resolved for member 'System.Data.Entity.Migrations.Design.ToolingFacade+GetContextTypeRunner,EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
       at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
       at System.Data.Entity.Migrations.Design.ToolingFacade.Run(BaseRunner runner)
       at System.Data.Entity.Migrations.Design.ToolingFacade.GetContextType(String contextTypeName)
       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)
    Type is not resolved for member 'System.Data.Entity.Migrations.Design.ToolingFacade+GetContextTypeRunner,EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

    The two common things that I can see for this error is a Versioning difference between projects (all are set to 4.5) and special characters (such as & and other things).  I do have periods in my names, but don't they they are special characters.  

    I have the solution setup with the following projects:

    Tool.Data.Models (holds the models)
    Tool.Data (holds the EF Context)
    Tool.Interfaces 
    Tool.Logic (Holds the logic layer)

    Any thoughts would be appreciated,


    Robert Johnston

    Friday, May 22, 2015 1:20 PM

Answers

  • Hello Robert,

    >>I am getting the following error when I try to run Enable Mirgrations

    This is strange since  I also created a similar scenario as below,

    Entity in a separate class library project:

    namespace CFModels
    
    {
    
        [Table("Post")]
    
        public class Post
    
        {
    
            [Key]
    
            public int ID { get; set; }
    
            public string Name { get; set; }
    
        }
    
    }


    Context class in another separate project

    namespace CFs
    
    {
    
        public class SC20150430 : DbContext
    
        {
    
            public DbSet<Post> Posts { get; set; }
    
        }
    
    }

    Migration Commands:

    Enable-Migrations

    Add-Migration CreateDatabase

    Update-Database

    Then using migration command to create the database and do other migration operations. My worked environment is windows  8.1, VS2013, .NET 4.5, EF 6 with SQL Server 2012.

    For this issue, i suggest you could check:

    If it is a project issue:

    Create a new project with same entities and do the same migrations and do the migrations with the original project using migrate.exe manually without the nugget command tool: https://msdn.microsoft.com/en-us/data/jj618307.aspx?f=255&MSPPError=-2147217396, if they causes its migrations failed, please provide your project environment as your detail migration for your model, the database you are using and the Entity Framework version.(You could also try with my demo.)

    Visual Studio nugget command tool issue:

    Run the original project on a different Visual Studio on the same or a new machine to check if the project still crashes the Visual Studio, if so, I think the tool may not be installed correctly, you could post this feedback to Visual Studio forum or the NuGet forum(seems the forum is moved to the GITHUB).

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Monday, May 25, 2015 3:36 AM
    Moderator