ralmsdeveloper / EntityFrameworkCore.FirebirdSQL

FirebirdSQL database provider for Entity Framework Core.
Other
44 stars 26 forks source link

Token unknown #40

Open Cae2 opened 6 years ago

Cae2 commented 6 years ago

Hello, Im trying to implement this package and when I try to return simple query it works, for example:

var result = context.Blog.Take(10).ToList();

but if I try to use the relationship with "Posts" for example:

var result = context.Blog.Include(p => p.Posts).Take(10).ToList();

I got the error:

Dynamic SQL Error SQL error code = -104 Token unknown - line 1, column 25

I searched about this Token Error and found some information about ADO FirebirdClient is only tested for FB 3.0 (and I'm using FB 2.5). This is the cause or I'm doing something wrong?

Thank you

Andyriod commented 5 years ago

Same here. I try to create my database with code first migrations.

Unhandled Exception: FirebirdSql.Data.FirebirdClient.FbException: Dynamic SQL Error SQL error code = -104 Token unknown - line 9, column 32 __EFMigrationsHistory ---> FirebirdSql.Data.Common.IscException: Dynamic SQL Error SQL error code = -104 Token unknown - line 9, column 32

class Program
{
    static void Main(string[] args)
    {
        using (var dbcontext = new BloggingContextFb())
        {
            dbcontext.Database.Migrate();
        }
        Console.ReadLine();
    }
}
public class BloggingContextFb : BloggingContext
{
    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
    {
        var connectionStringBuilder = new FbConnectionStringBuilder();
        connectionStringBuilder.UserID = "SYSDBA";
        connectionStringBuilder.Password = "masterkey";
        connectionStringBuilder.Database = "d:/database/blogdb.fdb";
        connectionStringBuilder.DataSource = "localhost";
        connectionStringBuilder.Port = 3050;
        connectionStringBuilder.Pooling = true;
        connectionStringBuilder.MinPoolSize = 0;
        connectionStringBuilder.MaxPoolSize = 100;
        connectionStringBuilder.Dialect = 3;
        var connectionString = connectionStringBuilder.ConnectionString;

        optionsBuilder.UseFirebird(connectionString);
    }

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        modelBuilder.Entity<Blog>(builder =>
        {
            builder.HasIndex(e => e.BlogId)
                .HasName("Id")
                .IsUnique();
        });
        modelBuilder.Entity<Post>(builder =>
        {
            builder.HasIndex(e => e.PostId)
                .HasName("Id")
                .IsUnique();
        });
    }
}

public class Blog
{
    public int BlogId { get; set; }
    public string Url { get; set; }
    public int Rating { 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; }
}

The FirebirdSql.EntityFrameworkCore.Firebird from Jiri works well here, but doesn't create TRIGGERS and GENERATORS for Primary Keys.

ralmsdeveloper commented 5 years ago

Sorry folks I had a lot of work here in the company.

This will be corrected as soon as possible.