Refactoring
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using AMWD.Common.EntityFrameworkCore.Extensions;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace AMWD.Common.EntityFrameworkCore.Attributes
|
||||
{
|
||||
/// <summary>
|
||||
/// Property attribute to create indices and unique constraints in the database.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Requires <see cref="ModelBuilderExtensions.ApplyIndexAttributes(ModelBuilder)"/> to be called within <see cref="DbContext.OnModelCreating(ModelBuilder)"/>.
|
||||
/// </remarks>
|
||||
[AttributeUsage(AttributeTargets.Property, Inherited = false, AllowMultiple = false)]
|
||||
public class DatabaseIndexAttribute : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DatabaseIndexAttribute"/> class.
|
||||
/// </summary>
|
||||
public DatabaseIndexAttribute()
|
||||
{
|
||||
Name = null;
|
||||
IsUnique = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a name.
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether it is a unique constraint.
|
||||
/// </summary>
|
||||
public bool IsUnique { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user