码迷,mamicode.com
首页 > 数据库 > 详细

Entity Framework 6 Code First +MVC5+MySql/Oracle使用过程中的两个问题

时间:2016-06-23 18:52:19      阅读:730      评论:0      收藏:0      [点我收藏+]

标签:

1、

namespace Snapsia.Web.Models
{
    using System;
    using System.Data.Entity;
    using System.ComponentModel.DataAnnotations.Schema;
    using System.Linq;

    [DbConfigurationType(typeof(MySql.Data.Entity.MySqlEFConfiguration))]
    public partial class SnapsiaContext : DbContext
    {
        public SnapsiaContext()
            : base("name=SnapsiaContext")
        {
        }

        public virtual DbSet<InfluencersUser> InfluencersUser { get; set; }
        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
        }
    }
}

 

2、表“TableDetails”中列“IsPrimaryKey”的值为 DBNull

解决办法:

set global optimizer_switch=derived_merge=OFF;

 http://stackoverflow.com/questions/33575109/mysql-entity-the-value-for-column-isprimarykey-in-table-tabledetails-is

http://bugs.mysql.com/bug.php?id=79163

https://dev.mysql.com/doc/refman/5.7/en/switchable-optimizations.html

 

3、

[Table("TB_USER", Schema = "USER_SNAPSIA")]//dbo架构在oracle数据库为用户名
    public partial class TB_USER
    {
        [Key]
        [StringLength(50)]
        public string ID { get; set; }

        [StringLength(50)]
        public string USERNAME { get; set; }

        [StringLength(50)]
        public string PWD { get; set; }
    }
public partial class OrclContext : DbContext
    {
        public OrclContext()
            : base("name=OrclContext")
        {
        }
        public virtual DbSet<TB_USER> TB_USER { get; set; }
        public virtual DbSet<TB_SYYS> TB_SYYS { get; set; }
        public virtual DbSet<TB_CCT> TB_CCT { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.HasDefaultSchema("USER_SNAPSIA"); //dbo架构在oracle数据库为用户名

            modelBuilder.Entity<TB_USER>()
                .Property(e => e.ID)
                .IsUnicode(false);
        }
    }

 

Entity Framework 6 Code First +MVC5+MySql/Oracle使用过程中的两个问题

标签:

原文地址:http://www.cnblogs.com/OnlyDreams/p/5611740.html

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