开发者

mvc ef code first database creation map

was wondering if it's possible to point the visual web express to a specific folder when it builds the database using entity framework code first. this question stemmed from this one:

mvc connection string code first

anyway, i was able to successfully build the dbase using code first but sql server management studio is looking at a diff folder. is it possible to piont the web express to that folder whe开发者_如何学JAVAn creating the database or is it better to just point the sql server management studio to where it's building it to? (does that make sense?) i tried fiddling with the ssms properties but it still won't look at that folder..


It whole depends on the connection string. If you are using default connection string for web application it always creates database in App_Data folder - it is specified by AttachDbFilename=|DataDirectory|DatabaseFileName.mdf. Using this is recommended way if you want your web app to create database because it should have necessary privileges by default.

If you want to place the database "elsewhere" you should not use attached db file and instead let SQL server create database in its default location by calling omitting AttachDbFilename part of the connection string. This can require additional security configuration to allow web application to create the database.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜