I have a problem with Asp.Net when I'm trying to create a many to many relationship model, I get this error when trying to register an account :
Sequence contains no matching element
When I "disabled" my changes, I could register on the site normally so there are some errors in my models regarding the column structure I suppose but I'm unable to fix them myself. I want to create a many to many connection between my Bookmark
and Tag
tables and the many-many table should have following structure: Id
, BookmarkID
, TagID
.
Here are my models:
public class Bookmark
{
[Key]
public int BookmarkID { get; set; }
public string Url { get; set; }
public ApplicationUser UserId { get; set; }
public virtual ICollection<BookmarkTag> BookmarkTags { get; set; }
}
public class Tag
{
[Key]
public int TagID { get; set; }
[Column(TypeName="varchar(60)")]
public string TagName { get; set; }
public virtual ICollection<BookmarkTag> BookmarkTags { get; set; }
}
public class BookmarkTag
{
[Key, Column(Order = 0)]
public int BookmarkTagID { get; set; }
[Key, Column(Order = 1)]
public int BookmarkID { get; set; }
[Key, Column(Order = 2)]
public int TagID { get; set; }
public virtual Bookmark Bookmark { get; set; }
public virtual Tag Tag { get; set;}
}
Here is the error stack trace as well:
[InvalidOperationException: Sequence contains no matching element]
System.Linq.Enumerable.Single(IEnumerable1 source, Func
2 predicate) +2603017 System.Data.Entity.Utilities.DbProviderManifestExtensions.GetStoreTypeFromName(DbProviderManifest providerManifest, String name) +81
System.Data.Entity.ModelConfiguration.Configuration.Properties.Primitive.PrimitivePropertyConfiguration.ConfigureColumn(EdmProperty column, EntityType table, DbProviderManifest providerManifest) +87
System.Data.Entity.ModelConfiguration.Configuration.Properties.Primitive.PrimitivePropertyConfiguration.Configure(EdmProperty column, EntityType table, DbProviderManifest providerManifest, Boolean allowOverride, Boolean fillFromExistingConfiguration) +138
System.Data.Entity.ModelConfiguration.Configuration.Properties.Primitive.<>c__DisplayClass4.b__3(Tuple2 pm) +38
1 ts, Action
System.Data.Entity.Utilities.IEnumerableExtensions.Each(IEnumerable1 action) +130
1 propertyMappings, DbProviderManifest providerManifest, Boolean allowOverride, Boolean fillFromExistingConfiguration) +94
System.Data.Entity.ModelConfiguration.Configuration.Properties.Primitive.PrimitivePropertyConfiguration.Configure(IEnumerable
System.Data.Entity.ModelConfiguration.Configuration.Types.StructuralTypeConfiguration.ConfigurePropertyMappings(IList1 propertyMappings, DbProviderManifest providerManifest, Boolean allowOverride) +154
1 entitySets, DbProviderManifest providerManifest) +423
System.Data.Entity.ModelConfiguration.Configuration.Types.EntityTypeConfiguration.ConfigurePropertyMappings(DbDatabaseMapping databaseMapping, EntityType entityType, DbProviderManifest providerManifest, Boolean allowOverride) +585
System.Data.Entity.ModelConfiguration.Configuration.Types.EntityTypeConfiguration.Configure(EntityType entityType, DbDatabaseMapping databaseMapping, DbProviderManifest providerManifest) +177
System.Data.Entity.ModelConfiguration.Configuration.ModelConfiguration.ConfigureEntityTypes(DbDatabaseMapping databaseMapping, ICollection
System.Data.Entity.ModelConfiguration.Configuration.ModelConfiguration.Configure(DbDatabaseMapping databaseMapping, DbProviderManifest providerManifest) +376
System.Data.Entity.DbModelBuilder.Build(DbProviderManifest providerManifest, DbProviderInfo providerInfo) +444
System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection) +55
System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext) +61
System.Data.Entity.Internal.RetryLazy2.GetValue(TInput input) +123
1.Initialize() +53
System.Data.Entity.Internal.LazyInternalContext.InitializeContext() +616 System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) +18
System.Data.Entity.Internal.Linq.InternalSet
System.Data.Entity.Internal.Linq.InternalSet1.get_InternalContext() +16 System.Data.Entity.Infrastructure.DbQuery
1.System.Linq.IQueryable.get_Provider() +39 System.Data.Entity.QueryableExtensions.FirstOrDefaultAsync(IQueryable1 source, Expression
1 predicate, CancellationToken cancellationToken) +154 System.Data.Entity.QueryableExtensions.FirstOrDefaultAsync(IQueryable1 source, Expression
1 predicate) +163
Microsoft.AspNet.Identity.EntityFramework.d__6c.MoveNext() +472 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +99
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58 Microsoft.AspNet.Identity.CultureAwaiter1.GetResult() +59 Microsoft.AspNet.Identity.<ValidateUserName>d__4.MoveNext() +594 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +99
1.GetResult() +28 BookIT.Controllers.d__15.MoveNext() in D:\Projekti\CS\BookIT\BookIT\Controllers\AccountController.cs:155
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58 Microsoft.AspNet.Identity.<ValidateAsync>d__0.MoveNext() +266 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +99
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58 Microsoft.AspNet.Identity.<CreateAsync>d__0.MoveNext() +568 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +99
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58 Microsoft.AspNet.Identity.<CreateAsync>d__d.MoveNext() +483 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +99
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58 System.Runtime.CompilerServices.TaskAwaiter
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +99
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58
System.Web.Mvc.Async.TaskAsyncActionDescriptor.EndExecute(IAsyncResult asyncResult) +97
System.Web.Mvc.Async.<>c__DisplayClass37.b__36(IAsyncResult asyncResult) +17
System.Web.Mvc.Async.WrappedAsyncResult1.CallEndDelegate(IAsyncResult asyncResult) +10
1.End() +49
System.Web.Mvc.Async.WrappedAsyncResultBase
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +32
System.Web.Mvc.Async.AsyncInvocationWithFilters.b__3d() +50 System.Web.Mvc.Async.<>c__DisplayClass46.b__3f() +225 System.Web.Mvc.Async.<>c__DisplayClass33.b__32(IAsyncResult asyncResult) +10
System.Web.Mvc.Async.WrappedAsyncResult1.CallEndDelegate(IAsyncResult asyncResult) +10
1.End() +49
System.Web.Mvc.Async.WrappedAsyncResultBase
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +34
System.Web.Mvc.Async.<>c__DisplayClass2b.b__1c() +26 System.Web.Mvc.Async.<>c__DisplayClass21.b__1e(IAsyncResult asyncResult) +100
System.Web.Mvc.Async.WrappedAsyncResult1.CallEndDelegate(IAsyncResult asyncResult) +10
1.End() +49
System.Web.Mvc.Async.WrappedAsyncResultBase
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +27
System.Web.Mvc.Controller.b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +13
System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult) +29
1.End() +49
System.Web.Mvc.Async.WrappedAsyncResultBase
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +36 System.Web.Mvc.Controller.b__15(IAsyncResult asyncResult, Controller controller) +12
System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult) +22
1.End() +49
System.Web.Mvc.Async.WrappedAsyncResultBase
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +26
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10
System.Web.Mvc.MvcHandler.b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +21
System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult) +29
1.End() +49
System.Web.Mvc.Async.WrappedAsyncResultBase
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +28 System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9711525 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
Thanks in advance
Added:
if (ModelState.IsValid)
{
var user = new ApplicationUser { UserName = model.Email, Email = model.Email };
var result = await UserManager.CreateAsync(user, model.Password);
if (result.Succeeded)
{