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

InMemory creates new row for modified entries that do not exist #3953

Closed
rowanmiller opened this issue Dec 2, 2015 · 2 comments
Closed

InMemory creates new row for modified entries that do not exist #3953

rowanmiller opened this issue Dec 2, 2015 · 2 comments
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Milestone

Comments

@rowanmiller
Copy link
Contributor

The code below gives the following output, meaning that a new row gets created for the modified state entry even though no row with that key exists.

Modified
22 - blogs.msdn.com/dotnet
Press any key to continue . . .
using Microsoft.Data.Entity;
using System;
using System.Linq;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            using (var db = new BloggingContext())
            {
                db.Blogs.Update(new Blog { Id = 22, Url = "blogs.msdn.com/dotnet" });
                Console.WriteLine(db.ChangeTracker.Entries().Single().State);
                db.SaveChanges();
            }

            using (var db = new BloggingContext())
            {
                foreach (var item in db.Blogs)
                {
                    Console.WriteLine($"{item.Id} - {item.Url}");
                }
            }
        }
    }

    public class Blog
    {
        public int Id { get; set; }
        public string Url { get; set; }
    }

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

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            optionsBuilder.UseInMemoryDatabase();
        }
    }
}
@rowanmiller
Copy link
Contributor Author

Make sure we also test the delete case from #4515

@ajcvickers ajcvickers modified the milestones: 1.0.0-rc2, 1.0.0 Apr 14, 2016
@ajcvickers
Copy link
Contributor

Already fixed as part of #4680

@ajcvickers ajcvickers modified the milestones: 1.0.0-rc2, 1.0.0 Oct 15, 2022
@ajcvickers ajcvickers added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Oct 15, 2022
@ajcvickers ajcvickers removed their assignment Sep 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Projects
None yet
Development

No branches or pull requests

2 participants