【发布时间】:2015-11-16 05:36:04
【问题描述】:
我正在尝试在 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
我希望迁移脚手架架构更新以添加新表。相反,我收到错误“'System.Net.ServicePointManager' 的类型初始化程序引发了异常。”
我做错了什么,我该如何解决?
完整的错误跟踪是:
System.TypeInitializationException:类型初始化器 'System.Net.ServicePointManager' 引发了异常。 ---> System.TypeInitializationException:类型初始化程序 'System.Net.ComNetOS' 抛出异常。 ---> System.Configuration.ConfigurationErrorsException:元素 在本节中只能出现一次。 (C:\TFS\HXDMSRC\VisualCollections\Development\VCollectAPI\tmp140.tmp 第 16 行)在 System.Configuration.BaseConfigurationRecord.EvaluateOne(字符串 [] 键、SectionInput 输入、布尔 isTrusted、FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult) 在 System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean getLkg, Boolean getRuntimeObject, Object& 结果, Object& 结果运行时间对象)在 System.Configuration.BaseConfigurationRecord.GetSectionRecursive(字符串 configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject、布尔型 requestIsHere、Object& 结果、Object& 结果运行时间对象)在 System.Configuration.BaseConfigurationRecord.GetSectionRecursive(字符串 configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject、布尔型 requestIsHere、Object& 结果、Object& 结果运行时间对象)在 System.Configuration.BaseConfigurationRecord.GetSectionRecursive(字符串 configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject、布尔型 requestIsHere、Object& 结果、Object& 结果运行时间对象)在 System.Configuration.BaseConfigurationRecord.GetSection(字符串 配置密钥)在 System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(字符串 节名)在 System.Configuration.ConfigurationManager.GetSection(字符串 节名)在 System.Configuration.PrivilegedConfigurationManager.GetSection(字符串 节名)在 System.Diagnostics.DiagnosticsConfiguration.Initialize() 在 System.Diagnostics.DiagnosticsConfiguration.get_Sources() 在 System.Diagnostics.TraceSource.Initialize() 在 System.Net.Logging.InitializeLogging() 在 System.Net.ComNetOS..cctor() 上的 System.Net.Logging.get_On() --- 内部异常堆栈跟踪结束 --- 在 System.Net.ServicePointManager..cctor() --- 内部异常结束 堆栈跟踪 --- 在 System.Net.ServicePointManager.EnsureStrongCryptoSettingsInitialized() 在 Microsoft.VisualStudio.Platform.VsAppDomainManager.InitializeNewDomain(AppDomainSetup appDomainInfo) 在 System.AppDomain.CreateAppDomainManager() 在 System.AppDomain.Setup(Object arg) 在 System.AppDomain.nCreateDomain(字符串友好名称,AppDomainSetup setup, Evidence providedSecurityInfo, Evidence creatorsSecurityInfo, IntPtr parentSecurityDescriptor) 在 System.AppDomainManager.CreateDomainHelper(字符串友好名称, 证据 securityInfo, AppDomainSetup appDomainInfo) 在 System.AppDomainManager.CreateDomain(字符串友好名称,证据 securityInfo, AppDomainSetup appDomainInfo) 在 System.AppDomain.InternalCreateDomain(字符串友好名称,证据 securityInfo,AppDomainSetup 信息)在 System.AppDomain.CreateDomain(字符串友好名称,证据 securityInfo,AppDomainSetup 信息)在 System.Data.Entity.Migrations.Design.ToolingFacade..ctor(字符串 migrationsAssemblyName,字符串 contextAssemblyName,字符串 配置类型名称,字符串工作目录,字符串 配置文件路径、字符串数据目录、DbConnectionInfo 连接字符串信息)在 System.Data.Entity.Migrations.MigrationsDomainCommand.GetFacade(字符串 configurationTypeName, Boolean useContextWorkingDirectory) 在 System.Data.Entity.Migrations.AddMigrationCommand.Execute(字符串名称, 布尔力,布尔ignoreChanges)在 System.Data.Entity.Migrations.AddMigrationCommand.c__DisplayClass2.<.ctor>b__0() 在 System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(操作 command) 'System.Net.ServicePointManager' 的类型初始化器 抛出异常。
【问题讨论】:
标签: entity-framework ef-code-first azure-mobile-services entity-framework-migrations