Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions 0-Nine.Core/Entities/Property.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ public class Property : BaseModel
public string Description { get; set; } = string.Empty;

[JsonInclude]
[Display(Name = "Is Available?", Description = "Indicates if the property is currently available for lease")]
public bool IsAvailable { get; set; } = true;
[Display(Name = "Is Active?", Description = "Indicates if the property is active in the system")]
public bool IsActive { get; set; } = true;

[JsonInclude]
[StringLength(50)]
Expand Down
54 changes: 54 additions & 0 deletions 0-Nine.Core/Exceptions/DatabaseExceptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
namespace Nine.Core.Exceptions;

/// <summary>
/// Groups database-specific exceptions thrown by the Nine database layer.
/// </summary>
public static class DatabaseExceptions
{
/// <summary>
/// Thrown when the database schema is more than two major versions behind the
/// current release and cannot be bridged automatically. The database has been
/// copied to <see cref="SchemaNotSupportedException.BackupPath"/> before this
/// exception is thrown; the user must import their data via the application's
/// import workflow instead.
/// </summary>
public class SchemaNotSupportedException : Exception
{
/// <summary>Full path of the backup copy made before this exception was thrown.</summary>
public string BackupPath { get; }

public SchemaNotSupportedException(string backupPath)
: base(
"The database has an incompatible schema version and cannot be upgraded " +
$"automatically. A backup has been saved to: {backupPath}")
{
BackupPath = backupPath;
}
}

/// <summary>
/// Thrown when the database schema structure is invalid, unrecognised, or
/// internally inconsistent in a way that prevents normal operation.
/// </summary>
public class SchemaInvalidException : Exception
{
public SchemaInvalidException(string message) : base(message) { }

public SchemaInvalidException(string message, Exception inner)
: base(message, inner) { }
}

/// <summary>
/// Thrown when an era bridge migration step fails. Used inside
/// <c>ApplyFirstAncestorBridgeAsync</c> and <c>ApplySecondAncestorBridgeAsync</c>
/// to surface a descriptive failure without leaking raw SQL exception details to
/// the UI layer.
/// </summary>
public class MigrationException : Exception
{
public MigrationException(string message) : base(message) { }

public MigrationException(string message, Exception inner)
: base(message, inner) { }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
fieldInfo: typeof(Property).GetField("<Description>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
maxLength: 1000);

var isAvailable = runtimeEntityType.AddProperty(
"IsAvailable",
var isActive = runtimeEntityType.AddProperty(
"IsActive",
typeof(bool),
propertyInfo: typeof(Property).GetProperty("IsAvailable", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
fieldInfo: typeof(Property).GetField("<IsAvailable>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
propertyInfo: typeof(Property).GetProperty("IsActive", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
fieldInfo: typeof(Property).GetField("<IsActive>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
sentinel: false);

var isDeleted = runtimeEntityType.AddProperty(
Expand Down
17 changes: 17 additions & 0 deletions 1-Nine.Infrastructure/Data/DesignTimeDbContextFactory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;

namespace Nine.Infrastructure.Data;

/// <summary>
/// Design-time factory to allow dotnet-ef migrations to run without the full application host.
/// </summary>
public class DesignTimeDbContextFactory : IDesignTimeDbContextFactory<ApplicationDbContext>
{
public ApplicationDbContext CreateDbContext(string[] args)
{
var optionsBuilder = new DbContextOptionsBuilder<ApplicationDbContext>();
optionsBuilder.UseSqlite("DataSource=design-time-temp.db");
return new ApplicationDbContext(optionsBuilder.Options);
}
}
Loading
Loading