繁体   English   中英

将 PetaPoco v6 与 asp.NET 内核集成

[英]Integrate PetaPoco v6 with asp.NET core

我正在尝试将 petapoco 与我的 .NET 核心 MVC 应用程序一起使用,我已经按照另一个答案中的说明安装了 petapoco,但不知道下一步该做什么,我搜索了很多地方,但其中大多数人一直在使用以前版本的 petapoco 和不是最新的,有人可以帮忙并提供一些资源链接,说明我应该如何使用连接字符串将它与我的 SQL 服务器连接起来,因为现在他们的文档建议使用 PetaPoco.DBEntityGenerator 而不是 T4 模板,我有不知道如何使用它。

从阅读快速入门指南开始

要连接到您的数据库,您可以从给出的示例开始:

// Normal
var db = new PetaPoco.Database("connectionStringName");

// Or the fluent configuration (PostgreSQL as an example)
var db = DatabaseConfiguration.Build()
         .UsingConnectionString("Host=127.0.0.1;Username=petapoco;Password=petapoco;Database=petapoco;Port=5001")
         .UsingProvider<PostgreSQLDatabaseProvider>()
         .UsingDefaultMapper<ConventionMapper>(m =>
         {
             m.InflectTableName = (inflector, s) => inflector.Pluralise(inflector.Underscore(s));
             m.InflectColumnName = (inflector, s) => inflector.Underscore(s);
         })
         .Create();

V6 只更改了 package 并放弃了对 T4 之类的支持,但您不需要模板即可启动。 rest 同V5

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM