1

在 .net core 2.2 中创建了新项目并使用此包安装了 nuget 包linq2db.sqlserver我能够使用数据库优先方法进行 CRUD,但我需要知道如何使用代码优先方法进行 CRUD。

4

1 回答 1

1

Linq2Db 有一个链接https://linq2db.github.io/index.html ,它提供了有关如何创建 POCO 并基于它创建表的更多信息。

根据页面,一个简单的 POCO 可以这样:

using System;
using LinqToDB.Mapping;

[Table(Name = "Products")]
public class Product
{
  [PrimaryKey, Identity]
  public int ProductID { get; set; }

  [Column(Name = "ProductName"), NotNull]
  public string Name { get; set; }

  // ... other columns ...
}

然后您需要配置连接字符串。

于 2019-12-31T12:22:09.193 回答