Add project files.
This commit is contained in:
29
Gready_Poang.Migrations/Gready_Poang.Migrations.csproj
Normal file
29
Gready_Poang.Migrations/Gready_Poang.Migrations.csproj
Normal file
@ -0,0 +1,29 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFrameworks>
|
||||
net9.0-android;
|
||||
net9.0-ios;
|
||||
net9.0-maccatalyst;
|
||||
net9.0-windows10.0.19041
|
||||
</TargetFrameworks>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.8">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.8" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.8" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.8" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Gready_Poang.DataLayer\Gready_Poang.DataLayer.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
33
Gready_Poang.Migrations/Program.cs
Normal file
33
Gready_Poang.Migrations/Program.cs
Normal file
@ -0,0 +1,33 @@
|
||||
using GreadyPoang.DataLayer.Database;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Hosting; // Replace with your actual namespace
|
||||
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
using var host = CreateHostBuilder(args).Build();
|
||||
|
||||
// Resolve your DbContext
|
||||
var context = host.Services.GetRequiredService<DataContext>();
|
||||
context.Database.EnsureCreated();
|
||||
// Optional: Apply migrations at runtime
|
||||
context.Database.Migrate();
|
||||
|
||||
Console.WriteLine("Migration applied successfully.");
|
||||
}
|
||||
|
||||
static IHostBuilder CreateHostBuilder(string[] args) =>
|
||||
Host.CreateDefaultBuilder(args)
|
||||
.ConfigureServices((_, services) =>
|
||||
{
|
||||
var MauiDataPath = string.Empty;
|
||||
MauiDataPath = File.ReadAllText(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "MauiDataPath_GreadyPoang.txt"));
|
||||
var dbPath = Path.Combine(MauiDataPath, "PoangDB.db");
|
||||
services.AddDbContext<DataContext>(options =>
|
||||
options.UseSqlite($"Data Source={dbPath}"));
|
||||
});
|
||||
}
|
||||
|
||||
// dotnet ef migrations add FixHeatToRoundParams --project GreadyPoang.DataLayer --startup-project GreadyPoang.Migrations
|
||||
// dotnet ef database update --project GreadyPoang.DataLayer --startup-project GreadyPoang.Migrations
|
||||
Reference in New Issue
Block a user