![]() But when your table name is different from entity name, then you need to use TableName attribute which indicates the table for which the Poco class will be mapped to. It will be assumed that the table name will be the class name and the primary key will be ‘Id’ if it’s not specified. NPoco works by mapping the column names to the property names on the entity object. So create a folder named “Model” and create a new class “Product.cs” as follows, Now, we need to add Product entity model. ![]() So your project.json should look like this, (BTW if you are not knowing then, it’s time to say Bye-Bye Project.json and. If you don’t know about using Swagger then read how to add swagger to the ASP.NET Core WEB API To use NPoco ORM, we need to install following nuget package. We don’t need this for demo, so I deleted it. The default Web API template comes with a controller named “Value”. Let’s create an ASP.NET Core Web API project. )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON IDENTITY(1,1) NOT NULL,ĬONSTRAINT PRIMARY KEY CLUSTERED Open SQL Server Management Studio and create a new database called “NPocoDemo” or you can name it anything of your choice. In this post, we will be using SQL Server as a database with NPoco ORM. So in this post, let’s find out how to use NPoco ORM with ASP.NET Core for CRUD operations. NPoco is a fork of PetaPoco with a handful of extra features. ![]() NPoco is a simple C# micro-ORM that maps the results of a query onto a POCO object.
0 Comments
Leave a Reply. |