Could not load type 'XXX' from assembly 'XXX'. at.OnModelCreating(DbModelBuilder modelBuilder)

c# ef-code-first entity-framework entity-framework-6 visual-studio-2015

Question

I attempt to use EntityFramework Power tools to retrieve the model visually after I have developed my model in order to evaluate it, but I get the following error:

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeLoadException: Could not load type 'DomainClasses.CompanyLogo' from assembly 'DomainClasses, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. at DataLayer.FinanceModelContext.OnModelCreating(DbModelBuilder modelBuilder) at System.Data.Entity.Internal.LazyInternalContext.CreateModelBuilder()
at System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext) at System.Data.Entity.Internal.RetryLazy`2.GetValue(TInput input) at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
at System.Data.Entity.Internal.LazyInternalContext.get_ModelBeingInitialized() at System.Data.Entity.Infrastructure.EdmxWriter.WriteEdmx(DbContext


My Domain Class, which might be the issue

namespace DomainClasses
{
    public class CompanyLogo
    {
        public byte[] Logo { get; set; }

        public int CompanyId { get; set; }

        public virtual Company Company { get; set; }
    }
}

File for configuration:

public class CompanyLogoMappings:EntityTypeConfiguration<CompanyLogo>
    {
        public CompanyLogoMappings()
        {
            this.HasKey(c => c.CompanyId);
            this.HasRequired(c => c.Company).WithOptional(cl => cl.CompanyLogo);
        }
    }
1
0
7/29/2016 1:37:55 PM

Accepted Answer

After numerous detours, I discover the cause of this problem.

The domain class was added.CompanyLogo After the creation of the model usingEF power tools .

I construct the Domain Classes project and run the tool, and it works as a result.

0
7/31/2016 10:27:24 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow