Oracle with .Net Core

Oracle Managed Data Access For .Net Core On Nuget
Microsoft Entity Framework On Github
Oracle Provider Sample Project
EF Core Project structure
Nuget Package for Oracle Provider
Oracle Provider for .Net Core installed
public class Employee{    [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public Guid Id { get; set; }
public string Firstname { get; set; } [DataType(DataType.EmailAddress)]
public string Email { get; set; }
[DataType(DataType.Date)]
public DateTime SignUp { get; set; }
}
public class ApplicationDbContext : DbContext{    public DbSet<Employee> Employees { get; set; }protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseOracle("User Id = DemoUser; Password = Passw0rd; Data Source = 127.0.0.1:1521/ORCL");
}
}
public class Program
{
public static void Main(string[] args)
{
using (var context = new ApplicationDbContext())
{
Console.WriteLine("Hello");
}
Console.Read();
}
}
PM> add-migration InitialDataBase
$> dotnet ef migrations add InitialDataBase
PM> update-database
$> dotnet ef database update
var employee = new Employee
{
Firstname = "Vatthanachai",
Email = "vatthanachai.w@gmail.com",
SignUp = new DateTime(2011, 10, 14)
};
context.Employees.Add(employee);
context.SaveChanges();
var emp = context.Employees.SingleOrDefault(s => s.Email == "vatthanachai.w@gmail.com");if (emp != null)
{
emp.Firstname = "Vatthanachai Wongprasert";
emp.SignUp = new DateTime(2015, 6, 11);
context.Update(emp);
context.SaveChanges();
}
var emp = context.Employees.SingleOrDefault(s => s.Email == "vatthanachai.w@gmail.com");if (emp != null)
{
context.Remove(emp);
context.SaveChanges();
}

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
วัฒนชัย วงศ์ประเสริฐ

วัฒนชัย วงศ์ประเสริฐ

Rogue Planet

More from Medium

The Facilis framework for dotnet core — the primary key

Debugging 101 in Visual Studio 2022

【C#】Creational Patterns Prototype Mode

The best way to analyze .Net assemblies without Assembly.LoadFile(), beyond ReflectionOnlyLoad