vs2022使用XAF框架创建项目后,为什么找不到数据库
我们上一篇介绍了如何vs2022使用XAF框架创建XAF项目,但是使用SQL Server工具查看不了数据库文件
不清楚如何创建XAF项目,请参考上一篇博客:https://www.cnblogs.com/xielong/p/16004570.html
我们找到项目启动项下的App.config
查看App.config信息,我们可以看到配置信息,DataSource:(localdb)\mssqllocaldb,Catailog:XAFStudyDemo
<connectionStrings> <add name="EasyTestConnectionString" connectionString="Integrated Security=SSPI;Pooling=false;Data Source=(localdb)\mssqllocaldb;Initial Catalog=XAFStudyDemoEasyTest"/> <add name="ConnectionString" connectionString="Integrated Security=SSPI;Pooling=false;Data Source=(localdb)\mssqllocaldb;Initial Catalog=XAFStudyDemo" /> <!-- Use the following connection string to connect to a Jet (Microsoft Access) database: <add name="ConnectionString" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Password=;User ID=Admin;Data Source=XAFStudyDemo.mdb;Mode=Share Deny None;"/> --> </connectionStrings>
经过我仔细查找,我看到在 C:\Users\Hai 目录下(Hai的我电脑的账号名)
可以将App.Conifg更改为
<connectionStrings> <!--<add name="EasyTestConnectionString" connectionString="Integrated Security=SSPI;Pooling=false;Data Source=(localdb)\mssqllocaldb;Initial Catalog=XAFStudyDemoEasyTest"/> <add name="ConnectionString" connectionString="Integrated Security=SSPI;Pooling=false;Data Source=(localdb)\mssqllocaldb;Initial Catalog=XAFStudyDemo" />--> <!-- Use the following connection string to connect to a Jet (Microsoft Access) database: <add name="ConnectionString" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Password=;User ID=Admin;Data Source=XAFStudyDemo.mdb;Mode=Share Deny None;"/> --> <!--本地数据库时,使用 --> <add name="ConnectionString" connectionString="Integrated Security=SSPI;Pooling=false;Data Source=.;Initial Catalog=XAFStudyDemo" /> <!--远程数据库时,使用 --> <!--<add name="ConnectionString" providerName="System.Data.SqlClient" connectionString="Pooling=false;Data Source=192.168.3.204;Initial Catalog=XAFStudyDemo;User ID=sa;Password=sa" />--> </connectionStrings>
重新运行生成(XAF自动构建数据库),在SQL Server工具就可以看到XAFStudyDemo
平时多记记,到用时才能看看,记录你的进步,分享你的成果