Hello World Oracle (edit)
Entity Framework 6 vs Oracle
Oracle.ManagedDataAccess.dll
Oracle.ManagedDataAccess.EntityFramework.dll
EF6 CodeFisrt支持Oracle - Rick Carter - 博客园 (cnblogs.com)
Developing .NET Applications for Oracle Database (On-Premises)
Developing .NET Applications for Oracle Database (On-Premises) for .NET Core 3.1 or higher.
Build a .NET Application on the Oracle Database with Microsoft Visual Studio 2010
by John Paul Cook
Published June 2011
Build a .NET Application on the Oracle Database with Microsoft Visual Studio 2010
.NET Data Provider
Note: You can use Oracle.ManagedDataAccess NuGet package (.NET >= 4.0, database >= 10g Release 2).
ODP.NET, Unmanaged Driver: Oracle.DataAccess.Client.dll (for example namespace: Oracle.DataAccess.Types)
ODP.NET, Managed Driver: Oracle.ManagedDataAccess.dll (for example namespace: Oracle.ManagedDataAccess.Types)
Connection String
using Oracle.DataAccess.Client; // C#, ODP.NET Oracle managed provider
string oradb = "Data Source=OraDb;User Id=hr;Password=hr;";
string oradb = "Data Source=(DESCRIPTION=" + "(ADDRESS=(PROTOCOL=TCP)(HOST=ORASRVR)(PORT=1521))" + "(CONNECT_DATA=(SERVICE_NAME=ORCL)));" + "User Id=hr;Password=hr;";
OracleConnection conn = new OracleConnection(oradb);
try
{
conn.Open();
string sql = " select department_name from departments where department_id = 10"; OracleCommand cmd = new OracleCommand(sql, conn); cmd.CommandType = CommandType.Text;
OracleDataReader dr = cmd.ExecuteReader(); dr.Read(); label1.Text = dr["department_name"].ToString(); // Retrieve by column name label1.Text = dr.GetString(0).ToString(); // Return a .NET data type label1.Text = dr.GetOracleString(0).ToString(); // Return an Oracle data type
label1.Text = dr.GetInt16("department_id").ToString();
conn.Close();
conn.Dispose();
}
catch (OracleException ex) // catches only Oracle errors {
....
}
Development Environment
OS: Windows Server 2016
Oracle Server Database: Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
Show me the code
SELECT banner FROM v$version WHERE ROWNUM = 1;
alter session set "_ORACLE_SCRIPT"=true;
create user Manh identified by Manh;
grant dba to MyDb;
ALTER USER Manh ACCOUNT UNLOCK IDENTIFIED BY Manh;
select sys_guid() from dual
union all
select sys_guid() from dual
union all
select sys_guid() from dual