asp.netcore连接postgres数据库 codefirst
1,使用.netcore框架建立两个项目
2,在model项目建立数据表实体类
3,在model中添加数据库上下文
4,在codefirt项目中的appsettings.json中条件连接字符串
"ConnectionStrings": {
"DefaultConnection": "Host=xxx;Username=xxx;Password=xxx;Database=xxx"
}
5,在codefirst的startup中添加
6,"工具" ——> "NuGet程序管理器"——>"程序包管理控制台"
默认项目选择model
add-migration
update-database