First of all, I have not seen this error anywhere else, and I think this is not a copy, so please read the whole situation first.
Everything worked fine, then I tried to update one of my model classes ( the App class and the update is now left in the comments), which I will list below, and that I had this ugly error.
The model supporting the ApplicationDbContext context has changed since the database was created. It is recommended that you use Code First Migrations to update the database ( http://go.microsoft.com/fwlink/?LinkId=238269 ). in System.Data.Entity.CreateDatabaseIfNotExists 1.InitializeDatabase(TContext context) at System.Data.Entity.Internal.InternalContext.<>c__DisplayClassf 1.b__e () in System.Data.Entity.Internal.InternalContext.PerformInitializationActionalizationAction .Data.Entity.Internal.InternalContext.PerformDatabaseInitialization () in System.Data.Entity.Internal.LazyInternalContext.b__4 (InternalContext c) in System.Data.Entity.Internal.RetryAction 1.PerformAction(TInput input) at System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(Action . 1.Initialize() at System.Data.Entity.Internal.Linq.InternalSet 1.Include (string path) in System.Data.Entity.Infrastructure.DbQuery 1.Include(String path) at System.Data.Entity.QueryableExtensions.Include[T](IQueryable 1.Include(String path) at System.Data.Entity.QueryableExtensions.Include[T](IQueryable 1.Include(String path) at System.Data.Entity.QueryableExtensions.Include[T](IQueryable 1 source, string path) in System.Data.Entity.QueryableExtensions.Include [T, TProperty] ( 1 source, Expression IQueryable 1 source, Expression path 1 source, Expression 1) in Microsoft.AspNet .Identity.EntityFramework.UserStore 6.GetUserAggregateAsync(Expression filter 6.GetUserAggregateAsync(Expression 1) in Microsoft.AspNet.Identity.EntityFramework.UserStore 6.FindByNameAsync(String userName) at Microsoft.AspNet.Identity.UserManager 2.ame ) in Microsoft.AspNet.Identity.UserManager'2.d__12.MoveNext (The end of the stack trace from the previous location where the exception was thrown --- in System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (Task) in System.Runtime.CompilerServices .TaskAwaiter.HandleNonSuccessAndDebuggerNotification (Task TaskControl.A..d__2.MoveNext () in d: \ Proje cts \ FULL \ Control Panel \ ControlPanel.Web \ Controllers \ AccountController.cs: line 56
At first, I thought it might be a migration problem, so I completely deleted the database, turned on the migration again, added the Init migration, and updated the database using
update-database -force -verbose
Everything is going well, without any complaints, but whenever I try to access my site, I get a previous error. I migrated about ten times, unable to solve the problem.
Here are my domain classes (models):
public class App { [Key] [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public virtual int AppId { get; set; } //[Required] public virtual string FacebookId { get; set; } //[Required] public virtual string Secret { get; set; } public virtual List<User> Users { get; set; } public virtual List<Post> Posts { get; set; } //public virtual ApplicationUser Admin { get; set; } } public class Post { [Key] [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public virtual int PostId { get; set; } public virtual string Content { get; set; } public virtual string Link { get; set; } public virtual string Image { get; set; } public virtual bool IsSpecial { get; set; } //[Required] public virtual App App { get; set; } //[Required] public virtual DateTime? PublishDate { get; set; } } public class User { [Key] [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public virtual int UserId { get; set; } [MaxLength(500)] public virtual string FacebookId { get; set; } [MaxLength(500)] public virtual string Token { get; set; } //[Required] public virtual App App { get; set; } }
Here are my IdentityModels:
public class ApplicationUser : IdentityUser { public virtual List<App> Apps { get; set; } public bool? IsPremium { get; set; } [DataType(DataType.Date)] public DateTime? LastPublishDateTime { get; set; } } public class ApplicationDbContext : IdentityDbContext<ApplicationUser> { public ApplicationDbContext() : base("dCon") { } protected override void OnModelCreating(DbModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); modelBuilder.Entity<IdentityUser>().ToTable("Admins"); modelBuilder.Entity<ApplicationUser>().ToTable("Admins"); modelBuilder.Entity<IdentityUserRole>().ToTable("AdminRoles"); modelBuilder.Entity<IdentityUserLogin>().ToTable("Logins"); modelBuilder.Entity<IdentityUserClaim>().ToTable("Claims"); modelBuilder.Entity<IdentityRole>().ToTable("Roles"); } }
a7madx7 Mar 14 '14 at 15:01 2014-03-14 15:01
source share