您的位置:首页 > 编程语言 > ASP

ASP.NET Core 开发 - Entity Framework (EF) Core

2016-08-25 12:49 806 查看

EF Core 1.0 Database First http://www.cnblogs.com/linezero/p/EFCoreDBFirst.html

ASP.NET Core 开发 - Entity Framework (EF) Core,ASP.NET Core 操作数据库。

Entity Framework (EF) Core RC2 也发布了,可以适用于 .NET Core 及ASP.NET Core 。

EntityFrameworkCore SQLite 本篇文章以SQLite 数据库作为介绍。

目前 EF Core 支持的数据库:

Microsoft SQL Server

SQLite

Postgres (Npgsql)

SQL Server Compact Edition

InMemory (for testing purposes)

后面将会增加:

MySQL

IBM DB2

介绍完了,现在正式开始。

新建项目

这里我们选择 ASP.NET Core Web Application (.NET Core)



@model IEnumerable<EFCoreDemo.Models.User>

@{
ViewBag.Title = "用户";
}
<table class="table">
<tr>
<th>Id</th>
<th>用户名</th>
</tr>

@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Id)
</td>
<td>
@Html.DisplayFor(modelItem => item.UserName)
</td>
</tr>
}
</table>




View Code
http://localhost:5000/User



参考文档:https://docs.efproject.net/en/latest/platforms/aspnetcore/new-db.html


如果你觉得本文对你有帮助,请点击“推荐”,谢谢。

.NET Core 跨平台交流群: 550897034

博客示例代码:GitHub
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐