Git Product home page Git Product logo

Comments (4)

roji avatar roji commented on June 13, 2024 1

Thanks, I can indeed see the problem happening; the same is occuring for the SQL Server provider - opened dotnet/efcore#33413 to track this on the EF side, will wait for any discussion there first.

from efcore.pg.

roji avatar roji commented on June 13, 2024

Please post a minimal, runnable code sample.

from efcore.pg.

grzegorzkarolewski avatar grzegorzkarolewski commented on June 13, 2024
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;

await using var ctx = new BlogContext();
await ctx.Database.EnsureDeletedAsync();
await ctx.Database.EnsureCreatedAsync();

ctx.Blogs.Add(new Blog { Name = "foo" });
await ctx.SaveChangesAsync();

ctx.ChangeTracker.Clear();

var blog = ctx.Blogs.Single();
Console.WriteLine(blog.Id.Value);

public class BlogContext : DbContext
{
    public DbSet<Blog> Blogs { get; set; }

    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        => optionsBuilder
            .UseNpgsql(@"Host=localhost;Username=test;Password=test")
            .LogTo(Console.WriteLine, LogLevel.Information)
            .EnableSensitiveDataLogging();

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        modelBuilder.Entity<Blog>()
            .Property(b => b.Id)
            .UseIdentityAlwaysColumn()
            .HasConversion(i => i.Value, v => new BlogId { Value = v });
    }
}

public class Blog
{
    public BlogId Id { get; set; }
    public string? Name { get; set; }
}

public class BlogId
{
    public int Value;
}

from efcore.pg.

roji avatar roji commented on June 13, 2024

Thanks again for raising this @grzegorzkarolewski, the fix has been done for SQL Server on the EF side and I've just merged the corresponding fix here for 9.0.

from efcore.pg.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.