Asp.Net Mvc+Localdb数据库项目在IIS部署的配置

1、将数据库文件放到App_Data文件夹下

2、Web.config连接字符串配置

<add name="TestEntities" connectionString="Data Source=(localdb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\Test.mdf;Initial Catalog=Test;Integrated Security=True" />

EF(dbfirst、modelfirst)的配置

 <add name="TestEntities" connectionString="metadata=res://*/Models.TestModel.csdl|res://*/Models.TestModel.ssdl|res://*/Models.TestModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=(localdb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\Test.mdf;initial catalog=Test;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />

EF (codefirst)的配置 

  <add name="TestEntities" connectionString="Data Source=(localdb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\Test.mdf;Initial Catalog=Test;Integrated Security=True"  providerName="System.Data.SqlClient"/>

 Data Source为使用localdb的版本

3、更改IIS中应用程序池中高级中的标识为LocalSystem

 

posted @ 2017-08-30 15:07  576  阅读(771)  评论(0编辑  收藏  举报