//
using BlogDatabaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace BlogDatabaseImplement.Migrations
{
[DbContext(typeof(BlogDatabase))]
[Migration("20230518164254_Start")]
partial class Start
{
///
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.5")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("BlogDatabaseImplement.Model.Comment", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
b.Property("NewsId")
.HasColumnType("integer");
b.Property("Text")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("NewsId");
b.ToTable("Comments");
});
modelBuilder.Entity("BlogDatabaseImplement.Model.News", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
b.Property("Text")
.IsRequired()
.HasColumnType("text");
b.Property("Title")
.IsRequired()
.HasColumnType("text");
b.Property("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("News");
});
modelBuilder.Entity("BlogDatabaseImplement.Model.NewsTag", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
b.Property("Count")
.HasColumnType("integer");
b.Property("NewsId")
.HasColumnType("integer");
b.Property("TagId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("NewsId");
b.HasIndex("TagId");
b.ToTable("NewsTags");
});
modelBuilder.Entity("BlogDatabaseImplement.Model.Tag", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
b.Property("Name")
.IsRequired()
.HasColumnType("text");
b.Property("NewsId")
.HasColumnType("integer");
b.HasKey("Id");
b.ToTable("Tags");
});
modelBuilder.Entity("BlogDatabaseImplement.Model.User", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
b.Property("DateCreate")
.IsRequired()
.HasColumnType("text");
b.Property("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Users");
});
modelBuilder.Entity("BlogDatabaseImplement.Model.Comment", b =>
{
b.HasOne("BlogDatabaseImplement.Model.News", "News")
.WithMany("Comments")
.HasForeignKey("NewsId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("News");
});
modelBuilder.Entity("BlogDatabaseImplement.Model.News", b =>
{
b.HasOne("BlogDatabaseImplement.Model.User", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("BlogDatabaseImplement.Model.NewsTag", b =>
{
b.HasOne("BlogDatabaseImplement.Model.News", "News")
.WithMany("Tags")
.HasForeignKey("NewsId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("BlogDatabaseImplement.Model.Tag", "Tag")
.WithMany("News")
.HasForeignKey("TagId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("News");
b.Navigation("Tag");
});
modelBuilder.Entity("BlogDatabaseImplement.Model.News", b =>
{
b.Navigation("Comments");
b.Navigation("Tags");
});
modelBuilder.Entity("BlogDatabaseImplement.Model.Tag", b =>
{
b.Navigation("News");
});
#pragma warning restore 612, 618
}
}
}