EF Core is a modern object-database mapper for .NET. It supports LINQ queries, change tracking, updates, and schema migrations.
Перейти к файлу
Maurycy Markowski ee0a2ae126 bump version 2024-07-24 22:54:56 -07:00
.config Use placeholder value to fix CredScan (#33550) 2024-04-18 09:48:17 +02:00
.github [automated] Merge branch 'release/8.0' => 'main' (#34089) 2024-06-25 15:53:25 -07:00
benchmark Bump SQLitePCLRaw from 2.1.7 to 2.1.8 (#33790) 2024-05-23 09:07:58 -07:00
docs Update getting-and-building-the-code.md (#34100) 2024-06-28 15:23:17 +03:00
eng bump version 2024-07-24 22:54:56 -07:00
logo Add a logo (#32156) 2023-10-26 13:44:35 -07:00
rulesets Add entity splitting support to migration snapshot 2022-06-23 18:06:38 -07:00
src Better reporting for query cache hits and misses for OTEL. (#34267) 2024-07-23 21:20:22 +02:00
test [main] Update dependencies from dotnet/arcade (#34268) 2024-07-24 23:49:43 +00:00
tools Fix T4 files for VS 17.8 (#32651) 2024-01-04 10:22:42 -08:00
.editorconfig Automatic use of C# primary constructors (#32509) 2024-01-06 08:38:58 +02:00
.gitattributes Update git artifacts 2017-03-13 12:02:22 -07:00
.gitignore Generate type mappings in the compiled model. 2023-08-07 15:37:23 -07:00
Directory.Build.props Various fixes for issues in efcore-in-VMR build (#33540) 2024-04-15 12:16:14 -07:00
Directory.Build.targets Add OptimizeContext MSBuild target that runs on build (#33049) 2024-02-29 14:51:18 -08:00
EFCore.Cosmos.slnf Rename solution to EFCore.sln (#32344) 2023-11-20 10:30:45 +01:00
EFCore.Relational.slnf Rename solution to EFCore.sln (#32344) 2023-11-20 10:30:45 +01:00
EFCore.Runtime.slnf Rename solution to EFCore.sln (#32344) 2023-11-20 10:30:45 +01:00
EFCore.Sqlite.slnf Rename solution to EFCore.sln (#32344) 2023-11-20 10:30:45 +01:00
EFCore.Tools.slnf Rename solution to EFCore.sln (#32344) 2023-11-20 10:30:45 +01:00
EFCore.sln Use TokenCredential for Cosmos tests (#33956) 2024-06-11 13:44:45 -07:00
EFCore.sln.DotSettings Pregenerate SQL for precompiled queries (#33510) 2024-05-03 15:46:58 +03:00
LICENSE.txt Update license to MIT 2021-07-22 20:14:07 -07:00
Microsoft.Data.Sqlite.slnf Test new sqlite3mc SQLitePCLRaw bundle (#32562) 2023-12-08 20:15:46 +00:00
NuGet.config Update dependencies from https://github.com/dotnet/arcade build 20240516.3 (#33760) 2024-05-20 06:02:20 +00:00
README.md Add a logo (#32156) 2023-10-26 13:44:35 -07:00
activate.ps1 Consistent and idiomatic casing/formatting. (#33362) 2024-03-21 10:28:04 +01:00
activate.sh Add ability to submit helix job from command line (#20208) 2020-03-11 15:42:48 -07:00
azure-pipelines-public.yml Update Helix pools (#34231) 2024-07-16 00:44:29 -07:00
azure-pipelines-richnav.yml Replace explicit richCodeNavigationEnvironment in azure-pipelines-richnav.yml (#32082) 2023-11-06 14:27:02 +00:00
azure-pipelines.yml Update Helix pools (#34231) 2024-07-16 00:44:29 -07:00
build.cmd Unlink of file '.dotnet/dotnet.exe' failed. Should I try again? (y/n) 2022-02-15 13:36:15 -08:00
build.sh Unlink of file '.dotnet/dotnet.exe' failed. Should I try again? (y/n) 2022-02-15 13:36:15 -08:00
github-merge-flow.jsonc Onboard new inter-branch merge flow [Configuration] (#34050) 2024-06-25 13:54:00 -07:00
global.json [main] Update dependencies from dotnet/arcade (#34268) 2024-07-24 23:49:43 +00:00
helix.cmd Rename some references (#21757) 2020-07-23 09:59:50 -07:00
helix.sh Rename some references (#21757) 2020-07-23 09:59:50 -07:00
restore.cmd Unlink of file '.dotnet/dotnet.exe' failed. Should I try again? (y/n) 2022-02-15 13:36:15 -08:00
restore.sh Unlink of file '.dotnet/dotnet.exe' failed. Should I try again? (y/n) 2022-02-15 13:36:15 -08:00
startvs.cmd Update solutions to VS 2019 2019-02-05 17:02:19 -08:00
stylecop.json Update license to MIT 2021-07-22 20:14:07 -07:00
test.cmd Unlink of file '.dotnet/dotnet.exe' failed. Should I try again? (y/n) 2022-02-15 13:36:15 -08:00
test.sh Unlink of file '.dotnet/dotnet.exe' failed. Should I try again? (y/n) 2022-02-15 13:36:15 -08:00

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, 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-build NuGet packages, as shown above. Alternately, 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 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-build NuGet packages, as shown above. Alternately, 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