数据库创建成功(如下图,命令行可以访问数据库)
efcore 初始化创建失败
snapshot关联代码如下
// <auto-generated />
using System;
using FakeXieChengApi.DataBase;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace FakeXieChengApi.Migrations
{
[DbContext(typeof(AppDbContext))]
partial class AppDbContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "2.2.4-servicing-10062")
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.Entity("FakeXieChengApi.Models.TouristRoute", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd();
b.Property<DateTime>("CreateTime");
b.Property<DateTime?>("DepartureTime");
b.Property<string>("Description")
.IsRequired()
.HasMaxLength(1500);
b.Property<double?>("DiscountPresent");
b.Property<string>("Features");
b.Property<string>("Fees");
b.Property<string>("Notes");
b.Property<decimal>("OriginalPrice")
.HasColumnType("decimal(18, 2)");
b.Property<string>("Title")
.IsRequired()
.HasMaxLength(100);
b.Property<DateTime?>("UpdateTime");
b.HasKey("Id");
b.ToTable("TouristRoutes");
});
modelBuilder.Entity("FakeXieChengApi.Models.TouristRoutePicture", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<Guid>("TouristRouteId");
b.Property<string>("Url")
.HasMaxLength(100);
b.HasKey("Id");
b.HasIndex("TouristRouteId");
b.ToTable("TouristRoutePictures");
});
modelBuilder.Entity("FakeXieChengApi.Models.TouristRoutePicture", b =>
{
b.HasOne("FakeXieChengApi.Models.TouristRoute", "TouristRoute")
.WithMany("TouristRoutePictures")
.HasForeignKey("TouristRouteId")
.OnDelete(DeleteBehavior.Cascade);
});
#pragma warning restore 612, 618
}
}
}
. Net Core实战+RESTful思想纵深课程,开发优雅RESTful风格API。
了解课程