.NET Core 中 EntityFrameworkCore的支持库主要有:

EntityFrameworkCore概览

 

 

 

Script-migration

 

级联删除

 protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            optionsBuilder.UseSqlServer("Data Source=10.10.10.237;Initial Catalog=DEV_RLS;User ID=DEV_User;Password=Devuser2020;");
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<Sheet>().HasOne<UserOrg>(s=>s.UserOrg).WithMany().OnDelete(DeleteBehavior.Restrict);

        }

 

 

根据数据库生成模型

Scaffold-DbContext -Force "Data Source=.;Initial Catalog=Test;User Id =sa;Password=sa;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models/Test  -UseDatabaseName

 

https://www.learnentityframeworkcore.com/configuration/fluent-api/ondelete-method

https://docs.microsoft.com/en-us/ef/core/miscellaneous/cli/powershell

 

相关文章:

  • 2021-08-26
  • 2021-11-25
  • 2021-11-18
  • 2021-05-15
  • 2022-12-23
  • 2021-12-19
  • 2021-04-15
  • 2021-06-08
猜你喜欢
  • 2022-12-23
  • 2021-09-02
  • 2021-11-14
  • 2022-12-23
  • 2021-12-31
  • 2022-12-23
  • 2021-09-17
相关资源
相似解决方案