我尝试在Azure移动服务中执行实体框架代码优先迁移。我让项目在本地运行,并将这个新类添加到我的模型中:
using Microsoft.WindowsAzure.Mobile.Service;
using System;
namespace VCollectAPI.DataObjects
{
public class TagEdit : EntityData
{
public string EditedTagId { get; set; }
public string SourceTagName { get; set; }
public string ResultingTagName { get; set; }
public DateTime TimeOfEdit { get; set; }
}
}
我还将此属性添加到我的VCollectAPIContext:DbContext类
public DbSet<TagEdit> TagEdits { get; set; }
并在我的TagDomainManager中添加一行:EntityDomainManager类
if (changedItems.Contains("Name"))
{
_context.TagEdits.Add(new TagEdit { EditedTagId = current.Id, SourceTagName = current.Name, ResultingTagName = update.Name, TimeOfEdit = DateTime.UtcNow });
current.Name = update.Name;
}
在PMC(程序包管理器控制台)上,然后运行命令
Add-Migration RecordingTagEdits -Verbose
我希望在迁移脚手架中进行架构更新以添加新表。相反,我得到了错误&#34;&#39; System.Net.ServicePointManager&#39;的类型初始值设定项。抛出异常。&#34;
我做错了什么以及如何解决?
完整的错误跟踪是:
System.TypeInitializationException:类型初始值设定项 &#39; System.Net.ServicePointManager&#39;抛出一个例外。 ---&GT; System.TypeInitializationException:类型初始值设定项 &#39; System.Net.ComNetOS&#39;抛出一个例外。 ---&GT; System.Configuration.ConfigurationErrorsException:元素 本节只能出现一次。 (C:\ TFS \ HXDMSRC \ VisualCollections \开发\ VCollectAPI \ tmp140.tmp 第16行) System.Configuration.BaseConfigurationRecord.EvaluateOne(字符串[] keys,SectionInput输入,Boolean isTrusted,FactoryRecord factoryRecord,SectionRecord sectionRecord,Object parentResult)at System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord factoryRecord,SectionRecord sectionRecord,Object parentResult, Boolean getLkg,Boolean getRuntimeObject,Object&amp;结果,对象&amp; resultRuntimeObject)at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(字符串 configKey,Boolean getLkg,Boolean checkPermission,Boolean getRuntimeObject,Boolean requestIsHere,Object&amp;结果,对象&amp; resultRuntimeObject)at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(字符串 configKey,Boolean getLkg,Boolean checkPermission,Boolean getRuntimeObject,Boolean requestIsHere,Object&amp;结果,对象&amp; resultRuntimeObject)at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(字符串 configKey,Boolean getLkg,Boolean checkPermission,Boolean getRuntimeObject,Boolean requestIsHere,Object&amp;结果,对象&amp; resultRuntimeObject)at System.Configuration.BaseConfigurationRecord.GetSection(字符串 configKey) System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(字符串 sectionName)at System.Configuration.ConfigurationManager.GetSection(字符串 sectionName)at System.Configuration.PrivilegedConfigurationManager.GetSection(字符串 sectionName)at System.Diagnostics.DiagnosticsConfiguration.Initialize()at System.Diagnostics.DiagnosticsConfiguration.get_Sources()at System.Diagnostics.TraceSource.Initialize()at System.Net.Logging.InitializeLogging()at System.Net.ComNetOS..cctor()中的System.Net.Logging.get_On()--- 内部异常堆栈跟踪结束--- at System.Net.ServicePointManager..cctor()---内部异常结束 堆栈跟踪--- at System.Net.ServicePointManager.EnsureStrongCryptoSettingsInitialized() 在 Microsoft.VisualStudio.Platform.VsAppDomainManager.InitializeNewDomain(AppDomainSetup appDomainInfo)在System.AppDomain.CreateAppDomainManager()处 System.AppDomain.Setup(Object arg)at System.AppDomain.nCreateDomain(String friendlyName,AppDomainSetup 设置,Evidence providedSecurityInfo,Evidence creatorsSecurityInfo, IntPtr parentSecurityDescriptor)at System.AppDomainManager.CreateDomainHelper(String friendlyName, 证据securityInfo,AppDomainSetup appDomainInfo)at System.AppDomainManager.CreateDomain(String friendlyName,Evidence securityInfo,AppDomainSetup appDomainInfo)at System.AppDomain.InternalCreateDomain(String friendlyName,Evidence securityInfo,AppDomainSetup info)at System.AppDomain.CreateDomain(String friendlyName,Evidence securityInfo,AppDomainSetup info)at System.Data.Entity.Migrations.Design.ToolingFacade..ctor(字符串 migrationsAssemblyName,String contextAssemblyName,String configurationTypeName,String workingDirectory,String configurationFilePath,String dataDirectory,DbConnectionInfo connectionStringInfo)at System.Data.Entity.Migrations.MigrationsDomainCommand.GetFacade(字符串 configurationTypeName,Boolean useContextWorkingDirectory)at System.Data.Entity.Migrations.AddMigrationCommand.Execute(String name, 布尔力,布尔值ignoreChanges)at System.Data.Entity.Migrations.AddMigrationCommand&LT;&GT; c__DisplayClass2&LT; .ctor&GT; b__0() 在 System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(动作 命令)&System; Net.Net.ServicePointManager&#39;的类型初始值设定项。 抛出异常。
答案 0 :(得分:8)
检查你的web.config,可能有一些参数重复。
答案 1 :(得分:0)
我有下一个内部异常,这意味着我的myTextArea.getDocument().addDocumentListener(new DocumentListener()
{
@Override
public void insertUpdate(DocumentEvent documentEvent)
{
lineNumberingTextArea.updateLineNumbers();
}
@Override
public void removeUpdate(DocumentEvent documentEvent)
{
lineNumberingTextArea.updateLineNumbers();
}
@Override
public void changedUpdate(DocumentEvent documentEvent)
{
lineNumberingTextArea.updateLineNumbers();
}
});
部分高于connectionStrings
:
configSections