An item with the same key has already been added. After switching web hosts

NexT

New Member
I'm transferring a .NET Framework 4.0 site from 1 web host to another. The site on the existing hosting seems to be working as intended. However, after transferring the site files and database to the new hosting and then fixing the web.config connection string to point to the new db, I'm getting errors when trying to access a page that pulls from the database.I did not write the site, but it appears to be using a code-first setup.\[code\]Server Error in '/' Application.An item with the same key has already been added.Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.Exception Details: System.ArgumentException: An item with the same key has already been added.Source Error:Line 130: if ((_Jobs == null))Line 131: {Line 132: _Jobs = base.CreateObjectSet<Job>("Jobs");Line 133: }Line 134: return _Jobs;\[/code\]I've tried rebuilding the edmx file from the new database server after transferring the files. I know my connection string is working because I wrote a small test that connects to the database through the same connection string and it is able to retrieve data.The only change I've made to the code base after copying it from it's working state is to the web.config's db connection string.The only real notable difference from the old hosting versus the new hosting is that the old hosting was using SQLEXPRESS(unknown version), whereas the new hosting is using MSSQL 2008.Stack Trace:\[code\][ArgumentException: An item with the same key has already been added.] System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) +52 System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add) +9378779 System.Data.Metadata.Edm.ObjectItemAttributeAssemblyLoader.LoadRelationshipTypes() +650 System.Data.Metadata.Edm.ObjectItemAttributeAssemblyLoader.LoadTypesFromAssembly() +17 System.Data.Metadata.Edm.ObjectItemAssemblyLoader.Load() +25 System.Data.Metadata.Edm.ObjectItemAttributeAssemblyLoader.Load() +4 System.Data.Metadata.Edm.AssemblyCache.LoadAssembly(Assembly assembly, Boolean loadReferencedAssemblies, ObjectItemLoadingSessionData loadingData) +160 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) +166 System.Data.Metadata.Edm.ObjectItemCollection.LoadAssemblyFromCache(ObjectItemCollection objectItemCollection, Assembly assembly, Boolean loadReferencedAssemblies, EdmItemCollection edmItemCollection, Action`1 logLoadMessage) +316 System.Data.Metadata.Edm.ObjectItemCollection.ImplicitLoadAssemblyForType(Type type, EdmItemCollection edmItemCollection) +84 System.Data.Metadata.Edm.MetadataWorkspace.ImplicitLoadAssemblyForType(Type type, Assembly callingAssembly) +151 System.Data.Objects.ObjectContext.GetTypeUsage(Type entityCLRType) +35 System.Data.Objects.ObjectContext.GetEntitySetForNameAndType(String entitySetName, Type entityCLRType, String exceptionParameterName) +33 System.Data.Objects.ObjectContext.CreateObjectSet(String entitySetName) +66 PR.PRModel.PREntities.get_Jobs() in \\n5200-2\iis7_www\p\e\personallyrecommended.com.au\www\App_Code\PRModel.Designer.cs:132 Careers.LoadJob() in \\n5200-2\iis7_www\p\e\personallyrecommended.com.au\www\Careers.aspx.cs:24 Careers.Page_Load(Object sender, EventArgs e) in \\n5200-2\iis7_www\p\e\personallyrecommended.com.au\www\Careers.aspx.cs:16 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35 System.Web.UI.Control.OnLoad(EventArgs e) +91 System.Web.UI.Control.LoadRecursive() +74 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272 \[/code\]Connection String:\[code\]<connectionStrings><add name="PREntities" connectionString="metadata=res://*/App_Code.PRModel.csdl|res://*/App_Code.PRModel.ssdl|res://*/App_Code.PRModel.msl;provider=System.Data.SqlClient;provider connection string="Data Source=myserver.com;Initial Catalog=mydatabase;Persist Security Info=True;User ID=username;Password=password;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient" /><add name="ConnectionStringDB" connectionString="Data Source=myserver.com;Initial Catalog=mydatabase;Persist Security Info=True;User ID=username;Password=password" providerName="System.Data.SqlClient" /></connectionStrings>\[/code\]
 
Top