Click here to Skip to main content
15,891,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I started developing an MVC app on my laptop, which was running VS2013, and SQL server 2008 R2. I copied this project over to my desktop computer running Visual Studio 2013, SQL server 2012 Developer Edition.

When I run this MVC app from my Desktop, I get the following error on the line where I set the Initializer, as can be seen below:

C#
public class MvcApplication : System.Web.HttpApplication
    {
        protected void Application_Start()
        {
            Database.SetInitializer<LiquorContext>(new LiquorContextInitializer()); //Exception happens here
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
        }
    }


This is the exception I get:
Additional information: The type initializer for 'System.Data.Entity.DropCreateDatabaseAlways`1' threw an exception.

I have used Nuget console to update my packages, as follow:
Update-Package -reinstall EntityFramework
Update-Package -reinstall Microsoft.AspNet.Identity.EntityFramework
Update-Package -reinstall Microsoft.Owin.Host.SystemWeb
Update-Package -reinstall Microsoft.Owin.Security.Cookies

None of my attempts have worked so far, and I cannot figure out what needs to change to fix this.

Any help would be appreciated.

NB: I have noticed the Entity Framework version has changed from version 6.1.2 to 6.1.3, but I was receiving this error before I updated Entity Framework Package.
Posted
Updated 4-Jul-18 4:33am

1 solution

I was using Moq with my project. So I installed it and then installed its dependencies.
There is a chance that you are some dependencies.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900