mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
remove attributes from entity configs
This commit is contained in:
parent
2137f1e318
commit
732848b549
4 changed files with 5 additions and 53 deletions
|
|
@ -1,7 +1,6 @@
|
|||
using FilterLists.Data.Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace FilterLists.Data.EntityTypeConfigurations
|
||||
{
|
||||
|
|
@ -12,16 +11,13 @@ public virtual void Configure(EntityTypeBuilder<TBase> entityTypeBuilder)
|
|||
entityTypeBuilder.HasKey(b => b.Id);
|
||||
|
||||
entityTypeBuilder.Property(b => b.Id)
|
||||
.HasAnnotation("JsonIgnore", new JsonIgnoreAttribute())
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
entityTypeBuilder.Property(b => b.CreatedDateUtc)
|
||||
.HasAnnotation("JsonIgnore", new JsonIgnoreAttribute())
|
||||
.HasColumnType("TIMESTAMP")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
entityTypeBuilder.Property(b => b.ModifiedDateUtc)
|
||||
.HasAnnotation("JsonIgnore", new JsonIgnoreAttribute())
|
||||
.HasColumnType("TIMESTAMP")
|
||||
.ValueGeneratedOnUpdate();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using FilterLists.Data.Entities;
|
||||
using FilterLists.Data.Entities;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace FilterLists.Data.EntityTypeConfigurations
|
||||
{
|
||||
|
|
@ -10,66 +7,32 @@ public class FilterListTypeConfiguration : BaseEntityTypeConfiguration<FilterLis
|
|||
{
|
||||
public override void Configure(EntityTypeBuilder<FilterList> entityTypeBuilder)
|
||||
{
|
||||
entityTypeBuilder.Property(b => b.MaintainerId)
|
||||
.HasAnnotation("JsonIgnore", new JsonIgnoreAttribute());
|
||||
|
||||
entityTypeBuilder.Property(b => b.Description)
|
||||
.HasAnnotation("Description",
|
||||
new DescriptionAttribute(
|
||||
"A brief description of the list's functionality. Preferably, this is quoted (if non-English, translate to English via translator or Google Translate for consistency) from the list's documentation or composed by a maintainer of the list. If neither are available, a generic description should be composed by the FilterLists contributor."))
|
||||
.HasMaxLength(1022);
|
||||
|
||||
entityTypeBuilder.Property(b => b.DescriptionSourceUrl)
|
||||
.HasAnnotation("Description",
|
||||
new DescriptionAttribute(
|
||||
"The URL to the list's documentation page from which the description was quoted if applicable."))
|
||||
.HasAnnotation("Url", new UrlAttribute())
|
||||
.HasMaxLength(2083);
|
||||
|
||||
entityTypeBuilder.Property(b => b.DonateUrl)
|
||||
.HasAnnotation("Description",
|
||||
new DescriptionAttribute(
|
||||
"The URL to the list's donation page. This could be a custom PayPal or similar link, or a link to a web page discussing various donation options. Pull requests that include changes to this link will undergo further verification to prevent fraud."))
|
||||
.HasAnnotation("Url", new UrlAttribute())
|
||||
.HasMaxLength(2083);
|
||||
|
||||
entityTypeBuilder.Property(b => b.EmailAddress)
|
||||
.HasAnnotation("Description",
|
||||
new DescriptionAttribute("The email address for communicating issues or comments about the list."))
|
||||
.HasAnnotation("EmailAddress", new EmailAddressAttribute())
|
||||
.HasMaxLength(126);
|
||||
|
||||
entityTypeBuilder.Property(b => b.ForumUrl)
|
||||
.HasAnnotation("Description",
|
||||
new DescriptionAttribute(
|
||||
"The URL to the list's forum where issues, change requests, etc. are discussed."))
|
||||
.HasAnnotation("Url", new UrlAttribute())
|
||||
.HasMaxLength(2083);
|
||||
|
||||
entityTypeBuilder.Property(b => b.HomeUrl)
|
||||
.HasAnnotation("Description",
|
||||
new DescriptionAttribute(
|
||||
"The URL to the list's home page. Preferably, this is stated in the header of the list. Alternatively, it could be a custom domain, GitHub page, blog post, forum post, etc. that serves as a primary source of information for the list."))
|
||||
.HasAnnotation("Url", new UrlAttribute())
|
||||
.HasMaxLength(2083);
|
||||
|
||||
entityTypeBuilder.Property(b => b.IssuesUrl)
|
||||
.HasAnnotation("Description", new DescriptionAttribute("The URL to the list's GitHub Issues."))
|
||||
.HasAnnotation("Url", new UrlAttribute())
|
||||
.HasMaxLength(2083);
|
||||
|
||||
entityTypeBuilder.Property(b => b.Name)
|
||||
.HasAnnotation("Description",
|
||||
new DescriptionAttribute("The name of the list as stated by the list maintainer(s) in title case."))
|
||||
.IsRequired()
|
||||
.HasMaxLength(126);
|
||||
|
||||
entityTypeBuilder.Property(b => b.IssuesUrl)
|
||||
.HasAnnotation("Description",
|
||||
new DescriptionAttribute(
|
||||
"The URL to the list in raw text format. zip files and other formats are acceptable if no text format is available."))
|
||||
.IsRequired()
|
||||
.HasAnnotation("Url", new UrlAttribute())
|
||||
entityTypeBuilder.Property(b => b.ViewUrl)
|
||||
.HasMaxLength(2083);
|
||||
|
||||
base.Configure(entityTypeBuilder);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using FilterLists.Data.Entities;
|
||||
using FilterLists.Data.Entities;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace FilterLists.Data.EntityTypeConfigurations
|
||||
|
|
@ -10,22 +8,16 @@ public class MaintainerTypeConfiguration : BaseEntityTypeConfiguration<Maintaine
|
|||
public override void Configure(EntityTypeBuilder<Maintainer> entityTypeBuilder)
|
||||
{
|
||||
entityTypeBuilder.Property(b => b.Email)
|
||||
.HasAnnotation("Description", new DescriptionAttribute("The email address of the list maintainer."))
|
||||
.HasAnnotation("EmailAddress", new EmailAddressAttribute())
|
||||
.HasMaxLength(126);
|
||||
|
||||
entityTypeBuilder.Property(b => b.HomeUrl)
|
||||
.HasAnnotation("Description", new DescriptionAttribute("The URL to the list maintainer's home page."))
|
||||
.HasAnnotation("Url", new UrlAttribute())
|
||||
.HasMaxLength(2083);
|
||||
|
||||
entityTypeBuilder.Property(b => b.Name)
|
||||
.HasAnnotation("Description", new DescriptionAttribute("The name of the list maintainer."))
|
||||
.IsRequired()
|
||||
.HasMaxLength(126);
|
||||
|
||||
entityTypeBuilder.Property(b => b.TwitterHandle)
|
||||
.HasAnnotation("Description", new DescriptionAttribute("The Twitter handle of the list maintainer."))
|
||||
.HasMaxLength(126);
|
||||
|
||||
base.Configure(entityTypeBuilder);
|
||||
|
|
|
|||
|
|
@ -16,7 +16,8 @@ public static void AddFilterListsServices(this IServiceCollection services, ICon
|
|||
{
|
||||
services.AddSingleton(c => configuration);
|
||||
services.AddEntityFrameworkMySql().AddDbContextPool<FilterListsDbContext>(options =>
|
||||
options.UseMySql(configuration.GetConnectionString("FilterListsConnection")));
|
||||
options.UseMySql(configuration.GetConnectionString("FilterListsConnection"),
|
||||
b => b.MigrationsAssembly("FilterLists.Api")));
|
||||
services.TryAddScoped<IFilterListRepository, FilterListRepository>();
|
||||
services.TryAddScoped<IFilterListService, FilterListService>();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue