Head0nF1re
Head0nF1re
CC#
Created by BlindWiz on 1/4/2024 in #help
Creating a SqlConnection connection via connection string
Did you check SqlCpnnection in the docs: https://learn.microsoft.com/en-us/dotnet/api/system.data.sqlclient.sqlconnection?view=dotnet-plat-ext-8.0#examples The command is inside the using statement of SqlConnection. After the using statement the object is disposed
4 replies
CC#
Created by Sun「無用」 on 6/21/2023 in #help
✅ ef not being able to update database migrations
Just had problem finding the db lol
58 replies
CC#
Created by Sun「無用」 on 6/21/2023 in #help
✅ ef not being able to update database migrations
I followed the example and had no problem creating it
58 replies
CC#
Created by Sun「無用」 on 6/21/2023 in #help
✅ ef not being able to update database migrations
Dotnet version 6? 7?
58 replies
CC#
Created by Sun「無用」 on 6/21/2023 in #help
✅ ef not being able to update database migrations
I will try to create a new app here
58 replies
CC#
Created by Sun「無用」 on 6/21/2023 in #help
✅ ef not being able to update database migrations
Version 6?
58 replies
CC#
Created by Sun「無用」 on 6/21/2023 in #help
✅ ef not being able to update database migrations
It's a new app? Will try here
58 replies
CC#
Created by Sun「無用」 on 6/21/2023 in #help
✅ ef not being able to update database migrations
Anything?
58 replies
CC#
Created by Sun「無用」 on 6/21/2023 in #help
✅ ef not being able to update database migrations
Try with a full/absolute path
58 replies
CC#
Created by Sun「無用」 on 6/21/2023 in #help
✅ ef not being able to update database migrations
It's relative then. That's your problem I think
58 replies
CC#
Created by Sun「無用」 on 6/21/2023 in #help
✅ ef not being able to update database migrations
Ok, you said you have your path in appsetting.json. Is it an absolute or relative path?
58 replies
CC#
Created by Sun「無用」 on 6/21/2023 in #help
✅ ef not being able to update database migrations
I did understand, I'm asking if that happens the first time you use "dotnet ef database update" or the second time
58 replies
CC#
Created by Sun「無用」 on 6/21/2023 in #help
✅ ef not being able to update database migrations
Nvm, that happens on the initial migration / first update?
58 replies
CC#
Created by Sun「無用」 on 6/21/2023 in #help
✅ ef not being able to update database migrations
You said your first migration applied, no?
58 replies
CC#
Created by Sun「無用」 on 6/21/2023 in #help
✅ ef not being able to update database migrations
58 replies
CC#
Created by Sun「無用」 on 6/21/2023 in #help
✅ ef not being able to update database migrations
Do you have the path defined as an absolute path?
58 replies
CC#
Created by Sun「無用」 on 6/21/2023 in #help
✅ ef not being able to update database migrations
public BloggingContext()
{
var folder = Environment.SpecialFolder.LocalApplicationData;
var path = Environment.GetFolderPath(folder);
DbPath = System.IO.Path.Join(path, "blogging.db");
}

// The following configures EF to create a Sqlite database file in the
// special "local" folder for your platform.
protected override void OnConfiguring(DbContextOptionsBuilder options)
=> options.UseSqlite($"Data Source={DbPath}");
}
public BloggingContext()
{
var folder = Environment.SpecialFolder.LocalApplicationData;
var path = Environment.GetFolderPath(folder);
DbPath = System.IO.Path.Join(path, "blogging.db");
}

// The following configures EF to create a Sqlite database file in the
// special "local" folder for your platform.
protected override void OnConfiguring(DbContextOptionsBuilder options)
=> options.UseSqlite($"Data Source={DbPath}");
}
58 replies
CC#
Created by Sun「無用」 on 6/21/2023 in #help
✅ ef not being able to update database migrations
What's in Program.cs
58 replies
CC#
Created by Sun「無用」 on 6/21/2023 in #help
✅ ef not being able to update database migrations
Show it...
58 replies
CC#
Created by Sun「無用」 on 6/21/2023 in #help
✅ ef not being able to update database migrations
Do you think it's the same as what's shown in their example?
58 replies