-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error when specifying AttachDbFileName in connection string #2810
Comments
Please provide more details about your issue. |
I am trying to use migration commands to generate database: "dnx . ef migration apply". I get an error saying the database file cannot be attached as database xxxx but if I remove the "AttachDbFileName" section, it works fine and the database file is created in default location.
|
Thanks for updating. This is not a bug in EF 7. We pass-through the connection string to SqlClient. There may be a problem with your localdb setup. Feel free to re-open if you identify a problem with how EF 7 handles your connection string. |
Cross-reference: Cannot attach database file when using Entity Framework 7 Migration commands (on StackOverflow) |
I still think this is a bug, or a missing feature compared to EF6. It's quite annoying anyway.
EF6 seems to have some logic to handle this stuff, see I posted a hacky workaround for this at the stackoverflow question linked by @bricelam... |
@axelheer That sounds like a bug. |
It seems the original report might have just missed a few details, but it could have been the same issue that @axelheer is describing from the beginning. I will just reactivate for now. |
Beside not stripping CREATE DATABASE [MyDatabase]
ON (NAME = 'MyDatabase.mdf', FILENAME = 'C:\Path\To\MyDatabase.mdf')
LOG ON (NAME = 'MyDatabase_log.ldf', FILENAME = 'C:\Path\To\MyDatabase_log.ldf'); This also means we'll need to manually resolve the |
Yeah, makes sense. Thus, we need already three things:
I've already looked into your tests, but I've no idea how to write some kind of integration test to play through this whole scenario. |
FYI, all the logic for resolving paths was in SqlProviderServices.GetOrGenerateDatabaseNameAndGetFileNames for EF6. |
I may be able to solve that. Should I dive into it and prepare a PR? |
That would be awesome if you're willing! |
Okay, I'll give it a try then. |
Triage: if we don't take a PR (cc @axelheer) to have proper support in 1.1, the scope for the EF team would be to try to throw a better error. |
Hey guys, We just ran into this ourselves; looks like relative paths aren't supported with
Just wanted to express that here for other people who might be bumping into this. The "fix" is use absolute paths. |
Edit: look at #2810 (comment) for details on the bug.
When specifying AttachDbFileName in connection string, the following error appear: Unable to Attach database file as database xxxxxxx.
Please advise.
Thanks
The text was updated successfully, but these errors were encountered: