In the VS2010 development environment, we recommend that you use a third-party plug-in to connect to the database.OracleConnection Tool. There are many third-party plug-ins, such as dotconnect for oracle,ODP. NETAnd so on. In this article, we use Oracle's own ODP. NET to connect to the Oracle Data Source. Now ODP. NET can also supportEntity Data ModelEntity Framework ).
The database uses oracle 11G X86 and downloads two files from the oracle Official Website: win32_11gR2_database_1of2 and win32_11gr2_database204 F2.
You also need to download a set of oracle tools for. NET development, such as ODP. NET. The ODAC1120230Beta_EntityFramework file contains all the plug-ins. Install all.
Copy the tnsnames file in D: \ app \ milo \ product \ 11.2.0 \ client_1 \ Network \ Admin \ Sample to D: in the \ app \ milo \ product \ 11.2.0 \ client_1 \ Network \ Admin \ directory, edit the file, for example, according to your own DB Configuration:
- <data source alias> =
-
- (DESCRIPTION =
-
- (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
-
- (CONNECT_DATA =
-
- (SERVER = DEDICATED)
-
- (SERVICE_NAME = orcl)
-
- )
-
- )
Save the settings and create a connection to the service resource manager in.
Connection string:
- DATA SOURCE=
-
- (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))(CONNECT_DATA=(SID=orcl)));
-
- PERSIST SECURITY INFO=True;
-
- USER ID=SCOTT
In this way, you can directly create a data model through this connection.
This section describes how to use ODP. NET to connect to a database and create an object data model.