EF Core works with many different database technologies. In this video, see a demonstration of the usage of the SQLite and Azure Cosmos database providers.
- Hi, I'm Cam Soper. I'm a content developer working on .NET Docs here at Microsoft. And welcome back to Entity Framework Core 101. So far, we've looked at using Entity Framework Core, exclusively with SQL server. In this video, we're going to look at using Entity Framework Core with other database providers. The database provider is a layer in the EF core architecture that's responsible for the communication between Entity Framework Core and the database. It's a plugable architecture which means we can support all kinds of databases. The first database provider we're going to look at is SQLite. SQLite is an open source cross-platform embedded database technology. I'm starting with a web application where I've already got Microsoft.EntityFrameworkCore.Sqlite.design and.tools installed. To use the SQLite provider where I would previously use .UseSQLServer I'm going to instead of calling .UseSQLite and I'm passing in the connection string in the SQLite format. That connection string points to a local file here on my machine. I've created a new record. I'm going to use a tool to read SQLite databases. This is an open source tool available for download on the internet and we'll browse to the products table. As you can see, there's the Rope Pull toy I just added. The next database provider we're going to look at is a brand new database provider from the Microsoft Entity Framework Core team that supports Azure Cosmos DB. Cosmos DB is a cloud-based distributed, no SQL database which means that instead of being a relational database management system, it works with JSON Documents. Just as in my previous example I have a working web application and in this web application I've already added Microsoft.EntityFrameworkCore.Cosmos.design and.tools. We already have a working entity model and a working database context. We'll use the Use Cosmos method to pass in our connection information. And once again, I'll have to remind you don't include sensitive information in your code. One difference with Cosmos DB is that it doesn't support the concept of an auto-generated Int for a primary identifier. So I've changed the entity model so that our IDs will be strings and they'll be initialized to a new GUID or Globally Unique Identifier. Let's run the application and add a record to our Cosmos DB instance. Now that I've that record, we'll go over to the Azure portal refresh my list of items in my Cosmos DB instance, and you can see the squeaky bone I just added. These are just two of the possible database providers you can use with Entity Framework Core. Visit the Entity Framework Core Documentation to see the full list of supported providers. Some are provided by Microsoft and some are provided by the community. Support includes my SQL, Postgres Oracle, DB2 and others. In this video, we looked at how EFT Core uses database providers to support a plethora of different database technologies. In the next video, I'm going to show you tips to get the most performance out of your ETF Core applications.
Released
1/11/2021This course was created by Microsoft.NET. We are pleased to host this training in our library.
Share this video
Embed this video
Video: Database providers