I am using POCO approach on all my projects using Entity Framework. It's all good but I have one problem: It is creating database on my SQL Express, instead I want it to store my database in *.mdf file in App_Data folder.
Set an appropriate connection string in Web.config that makes use of the AttachDBFilename keyword.
<connectionStrings>
<add name="MyContextClassName"
connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=MyDatabase;Integrated Security=True;MultipleActiveResultSets=True;AttachDBFilename=|DataDirectory|MyDatabase.mdf;User Instance=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.