efcore README

The project's README from github.com/dotnet/efcore. As one markdown file: README.md.

Repository

build status test results

This repository is home to the following .NET Foundation projects. These projects are maintained by Microsoft and licensed under the MIT License.

EF Entity Framework Core

latest version preview version downloads

EF Core is a modern object-database mapper for .NET. It supports LINQ queries, change tracking, updates, and schema migrations. EF Core works with SQL Server, Azure SQL Database, SQLite, Azure Cosmos DB, MariaDB, MySQL, PostgreSQL, and other databases through a provider plugin API.

Installation

EF Core is available on NuGet. Install the provider package corresponding to your target database. See the list of providers in the docs for additional databases.

dotnet add package Microsoft.EntityFrameworkCore.SqlServer
dotnet add package Microsoft.EntityFrameworkCore.Sqlite
dotnet add package Microsoft.EntityFrameworkCore.Cosmos

Use the --version option to specify a preview version to install.

Daily builds

We recommend using the daily builds to get the latest code and provide feedback on EF Core. These builds contain latest features and bug fixes; previews and official releases lag significantly behind.

Basic usage

The following code demonstrates basic usage of EF Core. For a full tutorial configuring the DbContext, defining the model, and creating the database, see getting started in the docs.

using var db = new BloggingContext();

// Inserting data into the database
db.Add(new Blog { Url = "http://blogs.msdn.com/adonet" });
db.SaveChanges();

// Querying
var blog = db.Blogs
    .OrderBy(b => b.BlogId)
    .First();

// Updating
blog.Url = "https://devblogs.microsoft.com/dotnet";
blog.Posts.Add(
    new Post
    {
        Title = "Hello World",
        Content = "I wrote an app using EF Core!"
    });
db.SaveChanges();

// Deleting
db.Remove(blog);
db.SaveChanges();

Build from source

Most people use EF Core by installing pre-built NuGet packages, as shown above. Alternatively, the code can be built and packages can be created directly on your development machine.

Contributing

We welcome community pull requests for bug fixes, enhancements, and documentation. See How to contribute for more information.

Getting support

If you have a specific question about using these projects, we encourage you to ask it on Stack Overflow. If you encounter a bug or would like to request a feature, submit an issue. For more details, see getting support.

Microsoft.Data.Sqlite

latest version preview version downloads

Microsoft.Data.Sqlite is a lightweight ADO.NET provider for SQLite. The EF Core provider for SQLite is built on top of this library. However, it can also be used independently or with other data access libraries.

Installation

The latest stable version is available on NuGet.

dotnet add package Microsoft.Data.Sqlite

Use the --version option to specify a preview version to install.

Daily builds

We recommend using the daily builds to get the latest code and provide feedback on Microsoft.Data.Sqlite. These builds contain the latest features and bug fixes; previews and official releases lag significantly behind.

Basic usage

This library implements the common ADO.NET abstractions for connections, commands, data readers, and so on. For more information, see Microsoft.Data.Sqlite on Microsoft Docs.

using var connection = new SqliteConnection("Data Source=Blogs.db");
connection.Open();

using var command = connection.CreateCommand();
command.CommandText = "SELECT Url FROM Blogs";

using var reader = command.ExecuteReader();
while (reader.Read())
{
    var url = reader.GetString(0);
}

Build from source

Most people use Microsoft.Data.Sqlite by installing pre-built NuGet packages, as shown above. Alternatively, the code can be built and packages can be created directly on your development machine.

Contributing

We welcome community pull requests for bug fixes, enhancements, and documentation. See How to contribute for more information.

Getting support

If you have a specific question about using these projects, we encourage you to ask it on Stack Overflow. If you encounter a bug or would like to request a feature, submit an issue. For more details, see getting support.

See also

efcore (dotnet/efcore)

Searching Database…

14.8K ·GitHub
这是做什么的?EF Core 是 .NET 的一个现代对象-数据库映射器:你可以像操作普通对象一样查询和更新数据,它会帮你处理 LINQ 查询、变更跟踪、更新以及数据库结构迁移。
它是添加到 .NET 项目里的库,还是一个需要单独运行的工具?它是一个库:在 .NET 代码中引用 EF Core 的 NuGet 包即可。大多数人直接安装现成的包,而不是从源码自行构建。
怎么把它装到我的项目里?EF Core 发布在 NuGet 上——安装与你目标数据库匹配的提供程序包即可;如果想用预览版,可以加上 --version 选项。
它能搭配哪些数据库使用?SQL Server、Azure SQL Database、SQLite、Azure Cosmos DB、MariaDB、MySQL、PostgreSQL 等数据库都可以;一些不太常见的数据库可以通过提供程序插件 API 来支持。
用最新的稳定版就够了吗,还是想体验新功能得另找渠道?README 建议使用每日构建版(daily builds)来获取最新代码:预览版和正式发布版在新功能和缺陷修复方面明显滞后。
这个仓库里除了 EF Core 还有什么?还有 Microsoft.Data.Sqlite——一个轻量级的 SQLite ADO.NET 提供程序。EF Core 的 SQLite 提供程序就是在它基础上构建的,不过这个库也可以独立使用,或与其他数据访问库配合使用。
有没有适合第一个 EF Core 应用的教程?有——文档里提供了入门教程,会带你一步步完成 DbContext 的配置、模型定义以及数据库的创建。
Creator
dotnet
Size
238.2 MB
Stars
14.8K
Age
12y
Commits · 90 Days