Using the Code First Model
- Last Updated: April 16, 2026
- 1 minute read
- ADO.NET
- Documentation
The following procedure uses the Oracle ADO.NET Entity Framework data provider, and assumes that you already have the database schema available.
-
Create a new application, such as Windows Console, Windows Forms, or ASP.NET, in Visual Studio and add an Entity Data Model (see Step 1 through Step 5).
The model is added to the application.
namespace NameSpace { public class ModelContext : DbContext { public ModelContext () { } public ModelContext (string conn) : base(conn) { } public DbSet<TAB> Tabs { get; set; } } public class TAB { public string ID { get; set; } public string name { get; set; } public string col { get; set; } } } -
Define a connection with the same name as the context.
<connectionStrings> <add name="ModelContext" connectionString="host=host;port=151;user id=***;password=***;sid=sid; LicensePath=***" providerName="DDTek.Oracle" /> </connectionStrings> -
Instantiate the context:
ModelContext ctx = new ModelContext (); ctx.Tabs.Add(new TAB { ID = "ID1" }); ctx.SaveChanges();