EntityFrameworkCore概览
2017-09-15 15:51 huoit 阅读(242) 评论(0) 编辑 收藏 举报.NET Core 中 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
1、如果您觉得阅读本文对您有帮助,请点一下“推荐”按钮,您的“推荐”将是我最大的写作动力!
2、欢迎各位转载,但是未经作者本人同意,转载文章请在文章页面明显位置标明作者和原文连接,否则保留追究法律责任的权利。
作者博客: http://www.cnblogs.com/xmai/