21. (ASP.NET Core 1.0 & MVC) Entity Framework Core Overview

preview_player
Показать описание
This Entity Framework Core Overview video is part of the ASP.NET Core 1.0 beginner programming tutorial course hosted by Steve Bishop, and covers what Entity Framework is, why it is important to our application, and how it helps us to manage our data. The ASP.NET Core 1.0 beginner course is a free .NET tutorial series that helps beginning programmers learn the basics of ASP.NET Core 1.0. These free ASP.NET Core programming tutorials cover a variety of basic topics such as downloading and installing ASP.NET Core, setup and configuration of ASP.NET Core, the MVC architecture, Razor View engine, ASP.NET Identity, Entity Framework 7.0, and other topics. After watching this beginner series on ASP.NET Core 1.0, you should be able to create your own website or web application.

Рекомендации по теме
Комментарии
Автор

Hey Steve, You are doing fabulous job. This video series is priceless. Nice and clear. Learnt a lot. Thank you!

wijithawijenayake
Автор

Steve, I'm really looking forward to learning about EF from you! I have just gotten to the point in a project I'm working on where my users(just myself at the moment) can create an object containing some essential information and a guid. I also got my first MySQL server running and connected to my project, and I'm ready to learn how to automate the creation and storing of my objects, so I can move a little closer to my end product. Thanks for the great videos!

garrettdavid
Автор

Hey, Steve. I'm having some trouble just getting the basics set up with EF in ASP.NET Core. I believe I have all the dependencies set up correctly. However, when I try to create a new MVC Controller with views using EF, I get this error: "There is no entity type Ingredient on DbContext". I created a new project utilizing the ASP Web App template with single user auth, so it had EF installed and configured already. When I set up the two classes below in the new project, I got the same error, except dealing with the "Album" class, not "Ingredient."

public class Album {
public int AlbumId {get; set;}
public string Name {get; set;}
}

public class AlbumContext : DbContext {
public DbSet<Album> Albums {get; set;}
}

I've read that some people get the error for not specifying a key, but I have tried with the [Key] Data Annotation above AlbumId. Another guy had a problem with a many-to-many relationship, but I don't see how that could be relevant here. Have I done something wrong in this simple example or is it more likely that I need to update some package in my project?

garrettdavid
Автор

Great stuff!

With your coverage of EF Core, might I suggest a topic to cover in later videos? I've got my EF Core code-first database created and have a Genre class (for music genres) with a int Id and a string Name properties. I've figured out how to seed my databases at startup to populate my tables with sample data. In the case of Genres I have Jazz, Rock etc.

I want to use the data stored in the database for a drop-down list for a form using the 'Select' html taghelper in my Razor view. Most of the examples I've seen use a method of ViewBag and using initialisation list syntax in the ViewModel to create the Genre items for the Select taghelper. However, I already have these Genres stored in a DbSet<Genre> so in my controller with access to my database context, I would like to create my ViewModel with a 'public SelectList GenreList' property and populate that property with SelectListItem elements created from the list of Genre elements from my DbSet<Genre>, I would then pass this to the View to consume in the Select taghelper. I cannot for the life of me figure out the syntax to do this though and keep encountering generic List<> and MVC SelectItemList implicit conversion problems. I suspect it's my lack of Linq knowledge to access EF Core database and create new SelectListItem objects for the SelectList property in the ViewModel that's to blame :)

Looking forward to more ASP.Core 1.0 goodness.

dazecm
Автор

Hi Steve, if you also include design pattern (e.g. Repository Pattern) in your future video? I think its is important to get things right when coding. Thanks for the videos :) cheers

ptlh