ASP. net mvc uses the Petapoco micro ORM framework + NpgSql driver to connect to the PostgreSQL database (problem summary), petapocoorm

Source: Internet
Author: User

ASP. net mvc uses the Petapoco micro ORM framework + NpgSql driver to connect to the PostgreSQL database (problem summary), petapocoorm

The installation process is simple:

1. Before reading the code, we need to load NpgSql and Petapoco into the current project. I will use Nuget to add them to the current project, as shown below:

Install-Package Npgsql

 

Install-Package PetaPoco

 

2. Let's take a look at the important code in Web. config.

1> database connection string

<connectionStrings>    <add name ="Postgresql" connectionString="Server=127.0.0.1;User id=postgres;password=123;Database=mono_test;" providerName="Npgsql"/>  </connectionStrings>

 

2> NpgSql driver configuration file

<! -- Provider-driven configuration file --> <system. data> <DbProviderFactories> <add name = "Npgsql Data Provider" invariant = "Npgsql" support = "FF" description = ". net Framework Data Provider for Postgresql Server "type =" Npgsql. npgsqlFactory, Npgsql "/> </DbProviderFactories> </system. data>

3. Load Npgsql. dll and Mono. Security. dll to the vs project.

1> put the two dll files in a folder

 

Open:

Select:

Next step:

Finally:

Reference:

 

Last:

A demo basic function will be provided later. Background UI reference:

Thanks to the background UI contributed by Elight. MVC.

Sample:

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.