Error in Entity Framework - Code First Migrations

txt423

New Member
After making the migration I was trying to update-database but I am not being able to do so. I have that error: \[quote\] Cannot find the object "dbo.Livro" because it does not exist or you do not have permissions.\[/quote\]\[code\]public class Autor{ [Key] public int AutorId { get; set; } public virtual ICollection<Livro> Livros { get; set; } public virtual ICollection<Avaliacao> Avaliacoes { get; set; }}public class Avaliacao{ [Key] public int AvaliacaoId{ get; set; } public virtual Autor Autor { get; set; } public virtual Livro Livro { get; set; }}public class Livro{ [Key] public int LivroId { get; set; } public virtual Autor Autor { get; set; } public virtual ICollection<Avaliacao> Avaliacoes { get; set; }}protected override void OnModelCreating(DbModelBuilder modelBuilder){ modelBuilder.Conventions.Remove<PluralizingTableNameConvention>(); modelBuilder.Entity<Autor>().HasMany(p => p.Livros).WithRequired(p => p.Autor); modelBuilder.Entity<Autor>().HasMany(p => p.Avaliacoes).WithRequired(p => p.Autor); modelBuilder.Entity<Livro>().HasMany(p => p.Avaliacoes).WithRequired(p => p.Livro);}\[/code\]I read something about creating the table dbo.Livro first, but I read that this is possible in Sql Server and I don't know how to do this in EF code first...
 
Back
Top