2

I have an application that is running perfectly "on my machine", but when deploying to production the site works however I am having an issue with 1 entity framework piece of code.

My environment is a win8.1 machine running vs2013rc The Production environment is a server running 2008r2 Both are running sql2012.

To try troubleshooting I have copied the database from production into my local development environment. I have tried setting up IIS on my local machine and it works

EX MESSAGE

Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.

>STACK TRACE
   at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
   at System.Reflection.RuntimeModule.GetTypes()
   at System.Reflection.Assembly.GetTypes()
   at System.Data.Metadata.Edm.ObjectItemConventionAssemblyLoader.LoadTypesFromAssembly()
   at System.Data.Metadata.Edm.ObjectItemAssemblyLoader.Load()
   at System.Data.Metadata.Edm.AssemblyCache.LoadAssembly(Assembly assembly, Boolean loadReferencedAssemblies, ObjectItemLoadingSessionData loadingData)
   at System.Data.Metadata.Edm.AssemblyCache.LoadAssembly(Assembly assembly, Boolean loadReferencedAssemblies, KnownAssembliesSet knownAssemblies, EdmItemCollection edmItemCollection, Action`1 logLoadMessage, Object& loaderCookie, Dictionary`2& typesInLoading, List`1& errors)
   at System.Data.Metadata.Edm.ObjectItemCollection.LoadAssemblyFromCache(ObjectItemCollection objectItemCollection, Assembly assembly, Boolean loadReferencedAssemblies, EdmItemCollection edmItemCollection, Action`1 logLoadMessage)
   at System.Data.Metadata.Edm.ObjectItemCollection.ExplicitLoadFromAssembly(Assembly assembly, EdmItemCollection edmItemCollection, Action`1 logLoadMessage)
   at System.Data.Metadata.Edm.MetadataWorkspace.ExplicitLoadFromAssembly(Assembly assembly, ObjectItemCollection collection, Action`1 logLoadMessage)
   at System.Data.Entity.Internal.InternalContext.TryUpdateEntitySetMappingsForType(Type entityType)
   at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)
   at System.Data.Entity.Internal.Linq.InternalSet`1.Initialize()
   at System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext()
   at System.Data.Entity.Infrastructure.DbQuery`1.System.Linq.IQueryable.get_Provider()
   at System.Linq.Queryable.SingleOrDefault[TSource](IQueryable`1 source, Expression`1 predicate)
   at WebApplication.Areas.Config.Repository.ConfigRepository.InsertUpdateConfiguration(ConfigurationModel model)

My code is nothing special

public void InsertUpdateConfiguration(ConfigurationModel model)
{
    try
    {
        using (var db = new Entities())
        {
            LogMessage("InsertUpdate - "+model.StoreName);
            if (model == null)
            {
                LogMessage("model is null????????");
            }
            else
            {
                LogMessage("model is good - "+model.BusinessId);
            }
            var checkIfAdded = db.Configurations.SingleOrDefault(s => s.BusinessId == model.BusinessId);
            LogMessage("checkif added complete");
            //  LogMessage("checkedifadded"+checkIfAdded.BusinessId);
            if (checkIfAdded == null)
            {
                LogMessage("checkifadded = null");
                var config = new Configuration()
                {
               ....
                };
                db.VendConfigurations.Add(config);                   
            }
            else
            {
                LogMessage("checkifadded != null");

            }
            LogMessage("saving vend config");
            db.SaveChanges();
            LogMessage("Saved config");
        }
    }
    catch (Exception ex)
    {
        LogMessage("booooooo "+ex.Message);
        LogError(ex);
    }
}

The code is failing at line

var checkIfAdded = db.Configurations.SingleOrDefault(s => s.BusinessId == model.BusinessId);

As the next line of logging isn't called.

Cœur
  • 32,421
  • 21
  • 173
  • 232
Diver Dan
  • 9,723
  • 22
  • 91
  • 160

0 Answers0