Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

C#

Daniel Mallett
Daniel Mallett
14,582 Points

Entity Frameworks Comic Book Model Application.

Hi all,

I am currently working through the Entity Frameworks Basics course and creating the Comic Book Model Console Application. I am having trouble getting my application to display anything. On the first part of the course it is meant to display "The Amazing Spider-Man". It will load but I still have no joy. I've looked through the first lot of videos again to see if I have missed something but still nothing.

Anyone had this issue?

Thank you for your time.

1 Answer

HIDAYATULLAH ARGHANDABI
HIDAYATULLAH ARGHANDABI
21,058 Points

Daniel Mallett, Please post the snapshot of your work. -Check the DbContext class -Check the enable-migration (ADO.net model if you are working with ADO) -Update the database. -try to read one record from the database.

Daniel Mallett
Daniel Mallett
14,582 Points

I've checked the context class. the code for it is below. Were using dbo. Nothing shows in my command prompt. and the data bases don't show. using ComicBookGalleryModel.Models; using System; using System.Collections.Generic; using System.Data.Entity; using System.Linq; using System.Text; using System.Threading.Tasks;

namespace ComicBookGalleryModel { class Context : DbContext { public Context() { Database.SetInitializer(new DropCreateDatabaseIfModelChanges<Context>()); //Database.SetInitializer(new CreateDatabaseIfNotExists<Context>()); //Database.SetInitializer(new DropCreateDatabaseAlways<Context>()); }

    public DbSet<ComicBook> ComicBooks { get; set; }
}

}