Hello,
I search an example on the using of a counter.
My goal is to implement an auto incremented ID with Entity Framwork.
I have added a custom generator on a model Blog like this:
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Blog>().Property(b => b.Id).HasValueGenerator<IdGenerator<Blog>>();
}
And i try to implement the custom generator:
internal class IdGenerator<T>:ValueGenerator<T>
{
public override T Next(EntityEntry entry)
{
var bucket = entry.Context.GetService<INamedBucketProvider>().GetBucketAsync().Result;
return bucket.Increment($"{typeof(T).Name}Id")
}
}
bucket.Increment is mentioned here but the compiler says that IBucket has no member Increment.
I use CouchbaseNetClient 3.9.0 and Couchbase.EntityFrameworkCore 1.0.1