Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Key may not be empty #13

Closed
turowicz opened this issue Nov 2, 2020 · 11 comments
Closed

Key may not be empty #13

turowicz opened this issue Nov 2, 2020 · 11 comments
Assignees
Labels
bug Something isn't working

Comments

@turowicz
Copy link

turowicz commented Nov 2, 2020

I get the following exception when trying to create a schema.

image

Context:

    public class SqlContext : DbContext
    {
        private readonly IDbConnection _connection;

        public SqlContext()
        {
        }

        public SqlContext(IDbConnection connection)
        {
            _connection = connection;
        }

        public DbSet<UnitData> Header { get; set; }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            if (!optionsBuilder.IsConfigured)
            {
                var connection = new CassandraConnectionStringBuilder();

                connection.Username = "cassandra";
                connection.Password = "cassandra";
                connection.ContactPoints = new string[] { "localhost" };

                optionsBuilder.UseCassandra(connection.ConnectionString, opt =>
                {
                    opt.MigrationsHistoryTable(HistoryRepository.DefaultTableName, "test");
                });
            }
        }

        protected override void OnModelCreating(ModelBuilder builder)
        {
            builder.UsePropertyAccessMode(PropertyAccessMode.Property);
            builder.ForCassandraAddKeyspace("test", new KeyspaceReplicationSimpleStrategyClass(1));

            builder.Entity<UnitData>().ToTable(nameof(UnitData), "test");
            builder.Entity<UnitData>().Ignore(table => table.ETag);
            builder.Entity<UnitData>().Ignore(table => table.Timestamp);
            builder.Entity<UnitData>().Ignore(table => table.Values);
            builder.Entity<UnitData>().ForCassandraSetClusterColumns(table => new { table.RowKey });
            builder.Entity<UnitData>().HasKey(table => new
            {
                table.PartitionKey,
                table.RowKey
            });
        }
    }
@turowicz
Copy link
Author

turowicz commented Nov 2, 2020

cc @simpleidserver

@pluskal
Copy link
Contributor

pluskal commented Nov 2, 2020

I have a feeling that this is a duplicate of #10.

@turowicz
Copy link
Author

turowicz commented Nov 2, 2020

@pluskal I have seen that issue and have created the keyspace manually. I am trying to create tables automatically.

@simpleidserver
Copy link
Owner

We couldn't reproduce your issue. Can-you use the Nuget version "2.0.3" ?

@turowicz
Copy link
Author

turowicz commented Nov 4, 2020

@simpleidserver I get the same error on 2.0.3.

I have used the EF Migrations instead to sort this out. The bug is still there though.

@simpleidserver
Copy link
Owner

Sorry to answer you late, I was working on the CaseManagement Project.
Can-you transfer your project ? I will take a closer look :)

@Delta-38
Copy link

Hi, I've been seeing the same behaviour, calling EnsureCreated or EnsureCreatedAsync results in the mentioned exception.
This can be verified even with the sample project when calling dbContext.Database.EnsureCreated().

@simpleidserver simpleidserver self-assigned this Nov 12, 2020
@simpleidserver simpleidserver added the bug Something isn't working label Nov 12, 2020
thabart added a commit that referenced this issue Nov 12, 2020
@turowicz
Copy link
Author

@simpleidserver the code pasted above is the project. The Program.cs only creates the context and calls EnsureCreatedAsync.

@simpleidserver
Copy link
Owner

The issue is fixed in the branch "release/2.0.4" :)

@Delta-38
Copy link

The issue is fixed in the branch "release/2.0.4" :)

I confirm it fixed the issue on my copy of the sample and on a personal project as well.

@turowicz
Copy link
Author

awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants