Skip to content
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

AttachDBFileName fails if the value includes |DataDirectory| #17723

Closed
mikeHag opened this issue Sep 9, 2019 · 8 comments
Closed

AttachDBFileName fails if the value includes |DataDirectory| #17723

mikeHag opened this issue Sep 9, 2019 · 8 comments

Comments

@mikeHag
Copy link

mikeHag commented Sep 9, 2019

I have a WPF Prism application working with Entity Framework Core 2.26. The OnConfiguring method optionsBuilder.UseSqlServer call includes the following in the connect string:
AttachDBFileName=|DataDirectory|\dbfiles\my.mdf;

I created a new project that uses .Net Core 3.0 Preview 9 and Entity Framework Core 3.0 Preview 9. At runtime the same connection string fails. I get a System.ArgumentException with the message "Invalid value for key 'attachdbfilename'."

"|DataDirectory|" appears to be the problem. AttachDBFileName with the full path works fine. If I build up the full path using the value AppDomain.CurrentDomain.BaseDirectory the attach will also work.

@ErikEJ
Copy link
Contributor

ErikEJ commented Sep 9, 2019

.NET Core SqlClient does not expand DataDirectory?

@mikeHag
Copy link
Author

mikeHag commented Sep 9, 2019

Yes, if I use "|DataDirectory|" the connection fails.

@bricelam
Copy link
Contributor

Duplicate of dotnet/SqlClient#16

@mikeHag
Copy link
Author

mikeHag commented Sep 12, 2019

Do not understand the reason for the closure. Code that worked with .Net, EF Core 2.26 and WPF does not work with .Net Core 3.0 Preview 9, EF Core 3.0 Preview 9 and Wpf. Oh well ...

@bricelam
Copy link
Contributor

This is not an issue with EF, but with SqlClient the issue dotnet/SqlClient#16 is tracking the work that needs to be done to fix it.

@bricelam
Copy link
Contributor

Please upvote it and subscribe to it for updates.

@ErikEJ
Copy link
Contributor

ErikEJ commented Nov 14, 2019

My PR to fix this has just been merged, and wil be part of the 1.1 release

@ajcvickers
Copy link
Contributor

@ErikEJ Awesome! Really appreciate your perseverance!

@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants