1

Created new project in .net core 2.2 and installed nuget package linq2db.sqlserver using this package i am able to do CRUD with database first approach but i need to know how to do CRUD using code first approach.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
RajPawar
  • 11
  • 2

1 Answers1

1

Linq2Db has a link https://linq2db.github.io/index.html which provides more information about how to create a POCO and create a table based on it.

As per the page, a simple POCO can go like this:

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 ...
}

Then you need to configure the connection strings.

Gauravsa
  • 6,330
  • 2
  • 21
  • 30
  • Referring the above given link I got to know which configurations to do, but it does not cleared that how the database and tables gets created based on code. How can I generate Database and tables based on my code – RajPawar Jan 03 '20 at 09:08