Advertisement
Ortund

Sequence contains no matching elements error

Jan 23rd, 2015
379
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.24 KB | None | 0 0
  1. /*I've narrowed the following error to the QuoteDBContext, which, when added to the modelBuilder, causes the error. Without this class added to the modelBuilder, I get another error that says "EntityType 'Quote' has no key defined. Define the key for this EntityType."*/
  2.  
  3. //QuoteDBContext (DBBaseObject just adds some context for columns inherited from elsewhere)
  4.     public class QuoteDBContext : DBBaseObject<Quote>
  5.     {
  6.         private static WebDBContext db = new WebDBContext();
  7.  
  8.         public QuoteDBContext()
  9.             : base()
  10.         {
  11.             Property(p => p.QuoteDate)
  12.                 .HasColumnName("dtQuoteDate")
  13.                 .HasColumnType("datetime");
  14.  
  15.             Property(p => p.QuoteValue)
  16.                 .HasColumnName("dQuoteValue")
  17.                 .HasColumnType("double");
  18.  
  19.             Property(p => p.Accepted)
  20.                 .HasColumnName("bAccepted")
  21.                 .HasColumnType("bit");
  22.  
  23.             ToTable("Quotes");
  24.         }
  25.     }
  26.  
  27. //Quote
  28.     public class Quote : BaseObject (BaseObject adds auditing columns)
  29.     {
  30.         public virtual Client Client { get; set; }
  31.         public DateTime QuoteDate { get; set; }
  32.         public double QuoteValue { get; set; }
  33.         public bool Accepted { get; set; }
  34.  
  35.         public Quote()
  36.         {
  37.             QuoteValue = 0;
  38.             Accepted = false;
  39.         }
  40.     }
  41.  
  42. /*The stacktrace:
  43.  
  44. System.InvalidOperationException was unhandled by user code
  45.   HResult=-2146233079
  46.   Message=Sequence contains no matching element
  47.   Source=System.Core
  48.   StackTrace:
  49.        at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source, Func`2 predicate)
  50.        at System.Data.Entity.Utilities.DbProviderManifestExtensions.GetStoreTypeFromName(DbProviderManifest providerManifest, String name)
  51.        at System.Data.Entity.ModelConfiguration.Configuration.Properties.Primitive.PrimitivePropertyConfiguration.Configure(EdmProperty column, EntityType table, DbProviderManifest providerManifest, Boolean allowOverride, Boolean fillFromExistingConfiguration)
  52.        at System.Data.Entity.ModelConfiguration.Configuration.Properties.Primitive.PrimitivePropertyConfiguration.<>c__DisplayClass1.<Configure>b__0(Tuple`2 pm)
  53.        at System.Data.Entity.Utilities.IEnumerableExtensions.Each[T](IEnumerable`1 ts, Action`1 action)
  54.        at System.Data.Entity.ModelConfiguration.Configuration.Properties.Primitive.PrimitivePropertyConfiguration.Configure(IEnumerable`1 propertyMappings, DbProviderManifest providerManifest, Boolean allowOverride, Boolean fillFromExistingConfiguration)
  55.        at System.Data.Entity.ModelConfiguration.Configuration.Types.StructuralTypeConfiguration.ConfigurePropertyMappings(IList`1 propertyMappings, DbProviderManifest providerManifest, Boolean allowOverride)
  56.        at System.Data.Entity.ModelConfiguration.Configuration.Types.EntityTypeConfiguration.ConfigurePropertyMappings(DbDatabaseMapping databaseMapping, EntityType entityType, DbProviderManifest providerManifest, Boolean allowOverride)
  57.        at System.Data.Entity.ModelConfiguration.Configuration.Types.EntityTypeConfiguration.Configure(EntityType entityType, DbDatabaseMapping databaseMapping, DbProviderManifest providerManifest)
  58.        at System.Data.Entity.ModelConfiguration.Configuration.ModelConfiguration.ConfigureEntityTypes(DbDatabaseMapping databaseMapping, DbProviderManifest providerManifest)
  59.        at System.Data.Entity.ModelConfiguration.Configuration.ModelConfiguration.Configure(DbDatabaseMapping databaseMapping, DbProviderManifest providerManifest)
  60.        at System.Data.Entity.DbModelBuilder.Build(DbProviderManifest providerManifest, DbProviderInfo providerInfo)
  61.        at System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection)
  62.        at System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext)
  63.        at System.Data.Entity.Internal.RetryLazy`2.GetValue(TInput input)
  64.        at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
  65.        at System.Data.Entity.Internal.LazyInternalContext.MarkDatabaseInitialized()
  66.        at System.Data.Entity.Database.Initialize(Boolean force)
  67.        at Jobber.Web.MvcApplication.Application_Start() in e:\Development\Jobber\Jobber.Web\Global.asax.cs:line 28
  68.   InnerException:*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement