zoukankan      html  css  js  c++  java
  • entityframwork

    entityframwork映射部分:

      public class NorthwindContext : DbContext
        {
    
    
          
    
            public DbSet<CATEGORIES> Categories { get; set; }
            public DbSet<CUSTOMERS> Customers { get; set; }
            public DbSet<EMPLOYEES> Employees { get; set; }
            public DbSet<PRODUCTS> Products { get; set; }
            public DbSet<ORDERS> Orders { get; set; }
            public DbSet<SUPPLIERS> Suppliers { get; set; }
            public DbSet<SHIPPERS> Shippers { get; set; }
            public DbSet<ORDER_DETAILS> Order_Details { get; set; }
           
    
            protected override void OnModelCreating(DbModelBuilder modelBuilder)
            {
    
                modelBuilder.Entity<CATEGORIES>().ToTable("CATEGORIES", "TEMP");
                modelBuilder.Entity<CUSTOMERS>().ToTable("CUSTOMERS", "TEMP");
                modelBuilder.Entity<EMPLOYEES>().ToTable("EMPLOYEES", "TEMP");
                modelBuilder.Entity<PRODUCTS>().ToTable("PRODUCTS", "TEMP");
                modelBuilder.Entity<ORDERS>().ToTable("ORDERS", "TEMP");
                modelBuilder.Entity<SUPPLIERS>().ToTable("SUPPLIERS", "TEMP");
                modelBuilder.Entity<SHIPPERS>().ToTable("SHIPPERS", "TEMP");
                modelBuilder.Entity<ORDER_DETAILS>().ToTable("ORDER_DETAILS", "TEMP");
                
    
             
                modelBuilder.Entity<SUPPLIERS>().HasMany(b => b.Products1).WithRequired(a => a.SUPPLIERS1);
                modelBuilder.Entity<EMPLOYEES>().HasMany(b => b.Employees1).WithRequired(a => a.Employees2);
                modelBuilder.Entity<CUSTOMERS>().HasMany(b => b.Orders).WithRequired(a => a.Customers);
                modelBuilder.Entity<EMPLOYEES>().HasMany(b => b.Orders).WithRequired(a => a.Employees);
                modelBuilder.Entity<CATEGORIES>().HasMany(b => b.Products).WithRequired(a => a.CATEGORIES);
                modelBuilder.Conventions.Remove<System.Data.Entity.ModelConfiguration.Conventions.ColumnTypeCasingConvention>();
    
    
           
           
                base.OnModelCreating(modelBuilder);
            }
        }
    

      

    STUDTY HARD FOR .NET
  • 相关阅读:
    彻底禁用resource manager
    NYOJ_94 cigarettes 递归VS迭代
    itunes connect上传截图提示无法加载文件问题
    hdu 1165 Eddy&#39;s research II(数学题,递推)
    USACO holstein 超时代码
    金蝶KIS标准版与金蝶K3的差别
    OC第三天(内存管理)
    HDU 1059 Dividing(多重背包)
    说说參数传递(泛型托付)
    Json数组操作小记 及 JSON对象和字符串之间的相互转换
  • 原文地址:https://www.cnblogs.com/zhishuru/p/3245200.html
Copyright © 2011-2022 走看看