码迷,mamicode.com
首页 > 其他好文 > 详细

Entity Framework

时间:2018-11-14 16:33:13      阅读:202      评论:0      收藏:0      [点我收藏+]

标签:tor   .sql   nav   指定表   方式   bool   mod   eset   映射关系   

  • 使用方式
    • DB FIrst
    • Model First
    • Code First
      • 可在OnModelCreating中自行指定表映射关系
        • modelBuilder.Entity<EntireInfo>().ToTable(currentLanguageViewName);
      • 消除no such table: __MigrationHistory和no such table: EdmMetadata错误
  • 判断表/视图是否存在(其实就是通过EF执行sql,也可以直接用ADO.NET,以SQLite为例)
    • 技术分享图片
                  bool isExisted = presetDataDB.Database.SqlQuery<int?>(@"
                           select * from sqlite_master where type = ‘table‘ and name = ‘{" + currentLanguageViewName + "}‘")
                           .SingleOrDefault() != null;
      View Code
  • EF中表/实体类的继承关系(https://weblogs.asp.net/manavi/inheritance-mapping-strategies-with-entity-framework-code-first-ctp5-part-1-table-per-hierarchy-tph)
    • TPH
    • TPT
    • TPC

modelBuilder

Entity Framework

标签:tor   .sql   nav   指定表   方式   bool   mod   eset   映射关系   

原文地址:https://www.cnblogs.com/wyp1988/p/9958291.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!