Cannot run Update-Database command

Cannot run Update-Database command

Postby navstev0 » Wed 01 Oct 2014 22:57

Hello I have been trying to run the command "Update-Database" and get the error Could not load file or assembly 'EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
My ef is version 6 so I am unsure why it is targeting version 5 and according to http://blog.devart.com/entity-framework-code-first-migrations-support-for-oracle-mysql-postgresql-and-sqlite.html it shouldn't be.

Here is the full output please help.
Code: Select all
PM> Update-Database
Specify the '-Verbose' flag to view the SQL statements being applied to the target database.
System.IO.FileLoadException: Could not load file or assembly 'EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
   at ComfortDental.Migrations.Configuration..ctor()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Data.Entity.Migrations.Utilities.MigrationsConfigurationFinder.FindMigrationsConfiguration(Type contextType, String configurationTypeName, Func`2 noType, Func`3 multipleTypes, Func`3 noTypeWithName, Func`3 multipleTypesWithName)
   at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.FindConfiguration()
   at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.GetMigrator()
   at System.Data.Entity.Migrations.Design.ToolingFacade.UpdateRunner.Run()
   at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
   at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
   at System.Data.Entity.Migrations.Design.ToolingFacade.Run(BaseRunner runner)
   at System.Data.Entity.Migrations.Design.ToolingFacade.Update(String targetMigration, Boolean force)
   at System.Data.Entity.Migrations.UpdateDatabaseCommand.<>c__DisplayClass2.<.ctor>b__0()
   at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command)

My web config is as such
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
  <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --></configSections>
  <connectionStrings>
    <add name="ComfortDb" connectionString="User Id=comfort;Password=xxxxx;Host=localhost;port=5432;Database=comfort;enlist=True" providerName="Devart.Data.PostgreSql" />
  </connectionStrings>
  <appSettings>
    <add key="enableSimpleMembership" value="false" />
    <add key="webpages:Version" value="2.0.0.0" />
    <add key="webpages:Enabled" value="false" />
    <add key="PreserveLoginUrl" value="true" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
    <add key="owin:AppStartup" value="ComfortDental.IdentityConfig" />
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
    <authentication mode="Forms">
      <forms loginUrl="~/Users/Login;Account" timeout="2880" />
    </authentication>
    <pages>
      <namespaces>
        <add namespace="System.Web.Helpers" />
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Optimization" />
        <add namespace="System.Web.Routing" />
        <add namespace="System.Web.WebPages" />
      </namespaces>
    </pages>
  </system.web>
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <handlers>
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
      <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
      <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers>
  </system.webServer>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="DotNetOpenAuth.Core" publicKeyToken="2780ccd10d57b246" />
        <bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="DotNetOpenAuth.AspNet" publicKeyToken="2780ccd10d57b246" />
        <bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-1.3.0.0" newVersion="1.3.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <entityFramework>
    <providers>
      <provider invariantName="Devart.Data.PostgreSql" type="Devart.Data.PostgreSql.Entity.PgSqlEntityProviderServices, Devart.Data.PostgreSql.Entity, Version=7.3.254.6, Culture=neutral, PublicKeyToken=09af7300eec23701" />
  </entityFramework>
</configuration>

Thanks.
navstev0
 
Posts: 3
Joined: Wed 01 Oct 2014 22:52

Re: Cannot run Update-Database command

Postby Shalex » Thu 02 Oct 2014 11:34

Please try adding the following entry in the assemblyBinding section of your web.config:
Code: Select all
      <dependentAssembly>
        <assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" />
        <bindingRedirect oldVersion="5.0.0.0" newVersion="6.0.0.0" />
      </dependentAssembly>

If this doesn't help, specify the version (x.xx.xx) of dotConnect for PostgreSQL currently installed on your workstation. You can find it via the Tools > PostgreSQL > About menu of Visual Studio.
Shalex
Devart Team
 
Posts: 7654
Joined: Thu 14 Aug 2008 12:44

Re: Cannot run Update-Database command

Postby navstev0 » Thu 02 Oct 2014 16:02

It is now throwing the following error, I did a check on the forms it find any information and found none.

Code: Select all
PM> Update-Database
Specify the '-Verbose' flag to view the SQL statements being applied to the target database.
System.TypeLoadException: Inheritance security rules violated by type: 'Devart.Common.Entity.Migrations.DbConnectionInfoBase'. Derived types must either match the security accessibility of the base type or be less accessible.
   at ComfortDental.Migrations.Configuration..ctor()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Data.Entity.Migrations.Utilities.MigrationsConfigurationFinder.FindMigrationsConfiguration(Type contextType, String configurationTypeName, Func`2 noType, Func`3 multipleTypes, Func`3 noTypeWithName, Func`3 multipleTypesWithName)
   at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.FindConfiguration()
   at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.GetMigrator()
   at System.Data.Entity.Migrations.Design.ToolingFacade.UpdateRunner.Run()
   at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
   at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
   at System.Data.Entity.Migrations.Design.ToolingFacade.Run(BaseRunner runner)
   at System.Data.Entity.Migrations.Design.ToolingFacade.Update(String targetMigration, Boolean force)
   at System.Data.Entity.Migrations.UpdateDatabaseCommand.<>c__DisplayClass2.<.ctor>b__0()
   at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command)
Inheritance security rules violated by type: 'Devart.Common.Entity.Migrations.DbConnectionInfoBase'. Derived types must either match the security accessibility of the base type or be less accessible.


The code first migration file is as follows.
Code: Select all
namespace ComfortDental.Migrations
{
    using System;
    using System.Data.Entity;
    using System.Data.Entity.Migrations;
    using System.Linq;

    internal sealed class Configuration : DbMigrationsConfiguration<ComfortDental.Areas.Shared.Models.DBDataContext>
    {
        public Configuration()
        {
            AutomaticMigrationsEnabled = true;
            SetSqlGenerator( Devart.Data.PostgreSql.Entity.Migrations.PgSqlConnectionInfo.InvariantName, new Devart.Data.PostgreSql.Entity.Migrations.PgSqlEntityMigrationSqlGenerator() );
        }

        protected override void Seed(ComfortDental.Areas.Shared.Models.DBDataContext context)
        {
        }
    }
}
navstev0
 
Posts: 3
Joined: Wed 01 Oct 2014 22:52

Re: Cannot run Update-Database command

Postby Shalex » Fri 03 Oct 2014 12:56

We cannot reproduce the problem at the moment. Please give us the following information:
1. If possible, send us a test project so that we can reproduce the problem in our environment.
2. Specify the version (x.xx.xx) of dotConnect for PostgreSQL currently installed on your workstation. You can find it via the Tools > PostgreSQL > About menu of Visual Studio.
3. Does your solution include several projects? Have you added the bindingRedirect section to the app.config of the project used by Package Manager Console?
4. Specify the version of target .NET Framework in your project.
5. Is .NET Framework v4.5 installed on your workstation?
6. Please confirm that migrate.exe from the projectfolder\packages\EntityFramework.6.1.1\tools\ folder works without this problem. (Although Package Manager Console doesn't depend on migrate.exe and uses a separate implementation)
Shalex
Devart Team
 
Posts: 7654
Joined: Thu 14 Aug 2008 12:44

Re: Cannot run Update-Database command

Postby navstev0 » Fri 03 Oct 2014 16:16

I have submitted a request as your subjected. Thanks for your speedy replies, and hopefully we can get this resolved quickly.
navstev0
 
Posts: 3
Joined: Wed 01 Oct 2014 22:52

Re: Cannot run Update-Database command

Postby Shalex » Mon 06 Oct 2014 15:10

navstev0 wrote:Inheritance security rules violated by type: 'Devart.Common.Entity.Migrations.DbConnectionInfoBase'. Derived types must either match the security accessibility of the base type or be less accessible.

This error occurs with the ComfortDental project. To fix the problem, please follow these steps:

1. Remove references to
\Program Files (x86)\Devart\dotConnect\PostgreSQL\Entity\EF5\Devart.Data.PostgreSql.Entity.dll
\Program Files (x86)\Devart\dotConnect\PostgreSQL\Entity\EF5\Devart.Data.PostgreSql.Entity.Migrations.dll
from your project and add the reference to
\Program Files (x86)\Devart\dotConnect\PostgreSQL\Entity\EF6\Devart.Data.PostgreSql.Entity.dll
because your project uses EF6.
Be aware that the EF6 Migrations functionality is included in \EF6\Devart.Data.PostgreSql.Entity.dll.

2. The 6.1.2-beta1 version of EntityFramework is not tested with dotConnect for PostgreSQL. The latest officially supported version of EntityFramework is 6.1.0 (http://www.devart.com/dotconnect/postgresql/revision_history.html). Please use 6.1.0.

Also we recommed you to remove EntityFramework v4.3.0 and EntityFramework v6.1.2-beta1 from your solution to avoid messing issues (remove them via Manage NuGet Packages tool and check the \ComfortProject\packages folder to make sure their folders are deleted completely).
Shalex
Devart Team
 
Posts: 7654
Joined: Thu 14 Aug 2008 12:44


Return to dotConnect for PostgreSQL