首页新闻找找看学习计划

ef6 连接oracle报错

0
悬赏园豆:10 [待解决问题]
        static void Main(string[] args)
        {
            Database.SetInitializer(new DropCreateDatabaseAlways<OracleDbContext>());
            using (OracleDbContext ctx = new OracleDbContext())
            {
                //查询
                if (ctx.AA_USER.Count() == 0)
                {
                }
                var users = ctx.AA_USER.OrderBy(p => p.ID);
                foreach (var u in users)
                {
                    Console.WriteLine("id:{0},name:{1}", u.USER_ID,u.USER_NAME);
                }
                Console.Write("Press any key to continue... ");
                Console.ReadLine();
            }
        }

    }
     public class aa_emp
     {
         public int EmployeeId { get; set; }
         public string Name { get; set; }
         public DateTime HireDate { get; set; }
         //public string Location { get; set; }
     }

     public class AA_USER
     {
         public int ID { get; set; }
         public int USER_ID { get; set; }
         public string USER_NAME { get; set; }
         //public string Location { get; set; }
     }
    public class OracleDbContext : DbContext
    {
        public OracleDbContext() :
            base("OracleDbContext") { }
        //public DbSet<aa_emp> aa_emps { get; set; }
        public DbSet<AA_USER> AA_USER { get; set; }

         protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            try
            {
                modelBuilder.HasDefaultSchema("biz_cw13.");
            }
            catch(Exception ex)
            {

            }
         }
     }

 

其中:OracleDbContext ctx = new OracleDbContext())

有异常:  ServerVersion: “ctx.Database.Connection.ServerVersion”引发了“System.InvalidOperationException”类型的异常

ctx.AA_USER也报错:是什么原因?

“System.ArgumentNullException”类型的未经处理的异常在 EntityFramework.dll 中发生

银杏叶儿的主页 银杏叶儿 | 初学一级 | 园豆:197
提问于:2015-06-24 17:10
< >
分享
所有回答(1)
0

为啥不用mybatis或者nhibernate?

傲慢与偏剑 | 园豆:381 (菜鸟二级) | 2015-06-25 12:58
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册