RUNNING THE APPLICATION
To enable the app to run it is necessary to edit the connection strings in appsettings.json .
The MySql string should have a 'password=mypassword' statement added to it
My preference is to make use of 'User Secrets' to avoid having to reveal the password.
They are easy to configure and are effective in removing passwords
from the solution
1. Right click on MssDapper project and select 'Manage User Secrets'
2. Copy and paste the ConnectionStrings key/value pair into secrets.json.
3. Add your password to the MySql connection in the secrets.json file only.
It should look like this
{
"ConnectionStrings": {
"MsSql": "Data Source=(localdb)\\ProjectModels;Initial Catalog=Northwind;Integrated Security=True",
"MySql": "Server=127.0.0.1;user ID=root;Password=yourPassword; Database=northwind"
}
}
4. Save secrets.json and add to the Configuration region in Program.cs
'builder.Configuration.AddUserSecrets<Program>();'
Configuration will look in secrets.json for the required connection strings before looking
in appsettings. If they are found, the connection strings in appsettings will not be used
To run with MySql or MariaDb databases, in Program.cs 'Add services' region replace
services.AddScoped<IConnectionCreator, MsSqlConnectionCreator>()
with:
services.AddScoped<IConnectionCreator, MySqlConnectionCreator>()
INSTALLING THE NORTHWIND DATABASE
The Sql 'Create Database' statements differ between TSql and MySql so you need to get
the right version
MySql Link: Zip file
https://www.aspsnippets.com/Handlers/DownloadFile.ashx?File=9cb579c6-86db-4596-84c3-d549428fdcf5.zip
In my version, the 'Notes' field in the 'Employees' table had the constraint 'Not null', that needs
to be edited and set to Null. To install, run the script in MySQL Workbench. If using MariaDb, use
HeidiSQL
TSql Microsoft Sql Server. Copy and paste from
https://github.com/microsoft/sql-server-samples/raw/master/samples/databases/northwind-pubs/instnwnd.sql
To install, run the script in Microsoft Sql Server Management Studio
没有合适的资源?快使用搜索试试~ 我知道了~
MssDapper.zip
共45个文件
cs:22个
cache:8个
json:5个
需积分: 5 0 下载量 91 浏览量
2023-07-18
14:30:44
上传
评论
收藏 71KB ZIP 举报
温馨提示
如何将Dapper扩展方法集成到ASP.NET应用程序中,作为实体框架的有用替代方法。
资源推荐
资源详情
资源评论
收起资源包目录
MssDapper.zip (45个子文件)
MssDapper
DataAccess
ConnectionCreator.cs 1KB
obj
DataAccess.csproj.nuget.g.targets 150B
DataAccess.csproj.nuget.dgspec.json 3KB
project.assets.json 33KB
DataAccess.csproj.nuget.g.props 1KB
Debug
net7.0
DataAccess.GeneratedMSBuildEditorConfig.editorconfig 515B
refint
.NETCoreApp,Version=v7.0.AssemblyAttributes.cs 198B
DataAccess.assets.cache 9KB
DataAccess.csproj.AssemblyReference.cache 95KB
DataAccess.AssemblyInfoInputs.cache 42B
ref
DataAccess.AssemblyInfo.cs 1003B
DataAccess.GlobalUsings.g.cs 295B
project.nuget.cache 2KB
Extensions.cs 3KB
MysqldataAccess.cs 5KB
ServerOptions.cs 508B
IConnectionCreator.cs 141B
bin
Debug
net7.0
DatabaseContext.cs 4KB
IDatabaseContext.cs 1KB
DataAccess.csproj 691B
MssDapper
Examples.cs 11KB
StoredProcedureId.cs 315B
obj
MssDapper.csproj.nuget.dgspec.json 6KB
MssDapper.csproj.nuget.g.targets 1KB
project.assets.json 137KB
MssDapper.csproj.nuget.g.props 2KB
Debug
net7.0
MssDapper.assets.cache 34KB
refint
.NETCoreApp,Version=v7.0.AssemblyAttributes.cs 198B
MssDapper.GlobalUsings.g.cs 295B
MssDapper.AssemblyInfo.cs 1000B
MssDapper.AssemblyInfoInputs.cache 42B
MssDapper.GeneratedMSBuildEditorConfig.editorconfig 513B
MssDapper.csproj.AssemblyReference.cache 114KB
ref
project.nuget.cache 8KB
ClassDefinitions.cs 1KB
TransactionExample.cs 3KB
Constants.cs 629B
bin
Debug
net7.0
Program.cs 1KB
Helper.cs 2KB
DemoA.cs 2KB
appsettings.json 608B
MssDapper.csproj 1004B
MenuItem.cs 780B
MssDapper.sln 2KB
ReadMe.txt 2KB
共 45 条
- 1
资源评论
寒冰屋
- 粉丝: 1006
- 资源: 578
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- com.Gaggle.fun.GooseGooseDuck.apk
- FastBrowser 基于CefSharp浏览器 Chromium内核 C#、WPF界面绘制, mp3、mp4播放
- apache-tomcat-8.5.100.tar.gz
- namehfyz1234
- 14727758_202405291911557049.csv.zip
- hfyzname1234
- 基于Java ME无线网络移动端的俄罗斯方块游戏的实现(源码+使用文档)
- 第九届上海市大学生网络安全大赛暨“磐石行动”2024第二届全国高校网络安全攻防活动 MISC wifi密码
- B07-GA503-2补充.zip
- 基于Java蚁群算法路由选择可视化(源码+使用文档)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功