这个错误让我感到非常难过
让我解释一下情景
我在解决方案中有以下项目
我正在尝试使用EF 6.0在Azure上的数据库上创建/更新表。
注意:
- 解决方案正在编译确定
- 我已将EF 6安装到3以上
- 我在Web服务项目的web.config文件和该类的app.config文件中添加了一个连接字符串(如下) 派生自DBcontext
System.InvalidOperationException: Sequence contains no matching element
at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source, Func`2
predicate)
at
System.Data.Entity.Utilities.DbProviderManifestExtensions.GetStoreTypeFromName(D
bProviderManifest providerManifest, String name)
at
System.Data.Entity.ModelConfiguration.Configuration.Properties.Primitive.Primiti
vePropertyConfiguration.ConfigureColumn(EdmProperty column, EntityType table,
DbProviderManifest providerManifest)
at
System.Data.Entity.ModelConfiguration.Configuration.Properties.Primitive.Primiti
vePropertyConfiguration.Configure(EdmProperty column, EntityType table,
DbProviderManifest providerManifest, Boolean allowOverride, Boolean
fillFromExistingConfiguration)
at
System.Data.Entity.ModelConfiguration.Configuration.Properties.Primitive.Primiti
vePropertyConfiguration.<>c__DisplayClass4.<Configure>b__3(Tuple`2 pm)
at System.Data.Entity.Utilities.IEnumerableExtensions.Each[T](IEnumerable`1
ts, Action`1 action)
at
System.Data.Entity.ModelConfiguration.Configuration.Properties.Primitive.Primiti
vePropertyConfiguration.Configure(IEnumerable`1 propertyMappings,
DbProviderManifest providerManifest, Boolean allowOverride, Boolean
fillFromExistingConfiguration)
at
System.Data.Entity.ModelConfiguration.Configuration.Types.StructuralTypeConfigur
ation.ConfigurePropertyMappings(IList`1 propertyMappings, DbProviderManifest
providerManifest, Boolean allowOverride)
at
System.Data.Entity.ModelConfiguration.Configuration.Types.EntityTypeConfiguratio
n.ConfigurePropertyMappings(DbDatabaseMapping databaseMapping, EntityType
entityType, DbProviderManifest providerManifest, Boolean allowOverride)
at
System.Data.Entity.ModelConfiguration.Configuration.Types.EntityTypeConfiguratio
n.Configure(EntityType entityType, DbDatabaseMapping databaseMapping,
DbProviderManifest providerManifest)
at
System.Data.Entity.ModelConfiguration.Configuration.ModelConfiguration.Configure
EntityTypes(DbDatabaseMapping databaseMapping, ICollection`1 entitySets,
DbProviderManifest providerManifest)
at
System.Data.Entity.ModelConfiguration.Configuration.ModelConfiguration.Configure
(DbDatabaseMapping databaseMapping, DbProviderManifest providerManifest)
at System.Data.Entity.DbModelBuilder.Build(DbProviderManifest
providerManifest, DbProviderInfo providerInfo)
at System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection)
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 context, XmlWriter writer)
at System.Data.Entity.Utilities.DbContextExtensions.<>c__DisplayClass1.<GetModel>b__0(XmlWriter w)
at System.Data.Entity.Utilities.DbContextExtensions.GetModel(Action`1 writeXml)
at System.Data.Entity.Utilities.DbContextExtensions.GetModel(DbContext context)
at System.Data.Entity.Migrations.DbMigrator..ctor(DbMigrationsConfiguration configuration, DbContext usersContext, DatabaseExistenceState existenceState, Boolean calledByCreateDatabase)
at System.Data.Entity.Migrations.DbMigrator..ctor(DbMigrationsConfiguration configuration)
at System.Data.Entity.Migrations.Design.MigrationScaffolder..ctor(DbMigrationsConfiguration migrationsConfiguration)
at System.Data.Entity.Migrations.Design.ToolingFacade.ScaffoldRunner.Run()
at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
at System.Data.Entity.Migrations.Design.ToolingFacade.Run(BaseRunner runner)
at System.Data.Entity.Migrations.Design.ToolingFacade.Scaffold(String migrationName, String language, String rootNamespace, Boolean ignoreChanges)
at System.Data.Entity.Migrations.AddMigrationCommand.Execute(String name, Boolean force, Boolean ignoreChanges)
at System.Data.Entity.Migrations.AddMigrationCommand.<>c__DisplayClass2.<.ctor>b__0()
at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command)
Sequence contains no matching element
PM&GT;添加迁移IntitalTableCreation
t = text(position1, position2, txt);
我知道当你使用first()而不是firstordefault()之类的东西时,这是一个错误。
可能出现什么问题?
任何帮助都将不胜感激。
欢迎任何疑问
连接字符串中的提供者名称是否有问题??
答案 0 :(得分:0)
唉!我不知道自己是怎么犯这么愚蠢的错误的!
在我的poco课程中,我试图将一个字节映射到一点!
AS如下!
[Column(TypeName = "BIT")]
public virtual System.Byte Status { get; set; }
一旦我纠正了这个错误,问题就解决了