I try to use app_data dynamic attached database. As I can see from source code should be supported? Attachdbfilename with DataDirectory?
Visual Studio ASP.NET core Project EF 2.1 (actual)
appsettings.json
"ConnectionString1": "Data Source=(localdb)\mssqllocaldb;AttachDbFilename=|DataDirectory|\rechnung.mdf;Integrated Security=True; MultipleActiveResultSets=True"
Startup.cs Startup
string appRoot = Directory.GetCurrentDirectory();
AppDomain.CurrentDomain.SetData("DataDirectory", Path.Combine(appRoot, "App_Data"));
configureservice
.AddDbContext
options.UseSqlServer(
Configuration.GetConnectionString("ConnectionString1"))
);
Modelclass constructor
public ModelRechnung(DbContextOptions
Exception on program.cs
ArgumentException: Invalid value for key 'attachdbfilename'.
at
var context = services.GetRequiredService
context.Database.EnsureCreated();
Maybe it only works with full .net framework?
Maybe it only works with full .net framework?
I am really curios you are answering "Maybe" and have no glue
Dupe of dotnet/corefx#19492
@bricelam sure? what is the function ExpandFileName in the sqlserver lib code, shown before?
I tried to get the step into F11 debugging working, to see what really happens at ensurecreated, but didnt work for me.
A overall issue is, keep versioning in track and changes. Works not in 2.0 can be solved in 2.1, who knows.
That code is so EF Core can handle |DataDirectory| when creating the database. SqlClient will also need to handle it when connecting to the database.
In other words, the EF code works as expected on .NET Framework, but SqlClient fails on .NET Core before that EF code has a chance to run.
I am not a Github Guru, but is that issue a corefx issue? I would expect as EF SQLClient issue?
SqlClient is a CoreFx property, not owned by the EF team
Most helpful comment
Dupe of dotnet/corefx#19492