运用数据库

    .NET 上有多个 ORM,其中有一个由微软开发,并默认包含在 ASP.NET Core 中,这就是 Entity Framework Core。Entity Framework Core 支持多个不同类型的数据库,并允许你使用 C# 代码创建数据库查询语句,查询结果映射回 C# 模型(POCO)。

    Entity Framework Core 可以连接到 SQL Server、PostgreSQL 和 MySQL 这种关系型数据库,也可以与 Mongo 这种 NoSQL(文档) 数据库协作。在本项目的开发过程中,你将使用一个 SQLite 数据库,以简化安装和配置的工作。


    Use a database

    There are a number of ORMs for .NET, including one built by Microsoft and included in ASP.NET Core by default: Entity Framework Core. Entity Framework Core makes it easy to connect to a number of different database types, and lets you use C# code to create database queries that are mapped back into C# models (POCOs).

    Entity Framework Core can connect to relational databases like SQL Server, PostgreSQL, and MySQL, and also works with NoSQL (document) databases like Mongo. During development, you’ll use SQLite in this project to make things easy to set up.