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 中发生
为啥不用mybatis或者nhibernate?