Skip to content

john182/EntityFrameworkCore.FirebirdSQL

 
 

Repository files navigation

EntityFrameworkCore.FirebirdSQL

FirebirdSQL database provider for Entity Framework Core.

FirebirdSQL Access Provider Using EntityFrameworkCore

Example of use

public class Context : DbContext
   {
       
       public DbSet<Blog> Blog { get; set; }
       public DbSet<Post> Posts { get; set; }
       protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
       { 

           string connectionString =
           "User=SYSDBA;" +
           "Password=masterkey;" +
           $"Database={AppContext.BaseDirectory}Rafael.fdb;" +
           "DataSource=localhost;" +
           "Port=2017;" +
           "Dialect=3;" +
           "Charset=NONE;" +
           "Role=;" +
           "Connection lifetime=15;" +
           "Pooling=true;" +
           "MinPoolSize=1;" +
           "MaxPoolSize=50;" +
           "Packet Size=8192;" +
           "ServerType=0";

           optionsBuilder.UseFirebirdSql(connectionString); 
            //if used Log
           //LoggerFactory loggerFactory = new LoggerFactory();
           //loggerFactory.AddProvider(new TraceLoggerProvider());
           //optionsBuilder.UseLoggerFactory(loggerFactory);

       }
       protected override void OnModelCreating(ModelBuilder modelo)
       {
           //Fluent Api
           modelo.Entity<Blog>(entity =>
           {
               entity.HasIndex(e => e.BlogId)
                   .HasName("Id")
                   .IsUnique();
           });
       }
   }

   public class Blog
   {
       public int BlogId { get; set; }
       public string Url { get; set; } 
       public List<Post> Posts { get; set; }
   }

   public class Post
   {
       public int PostId { get; set; }
       public string Title { get; set; }
       public string Content { get; set; }

       public int BlogId { get; set; }
       public Blog Blog { get; set; }
   }
}    

About

FirebirdSQL database provider for Entity Framework Core.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%