Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3784784
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T11:25:45+00:00 2026-05-19T11:25:45+00:00

ever since I read about Code-First I find out there might be a problem

  • 0

ever since I read about Code-First I find out there might be a problem with this (although its just a preview) I have 2 problem with EF4 CTP5 release as folowing:

As it said “New Change Tracking API”
but it dose’t tracking changes i
guess. In comparison with LINQ to SQL I
bring an example to see what
each method react:

LINQ to SQL:

Dim db2 As New LINQDataContext
Dim db3 As New LINQDataContext

db2.Product.FirstOrDefault(Function(m) m.ID = 100).Name = "Change1"
db3.Product.FirstOrDefault(Function(m) m.ID = 100).Name = "Change2"

db2.SubmitChanges()
db3.SubmitChanges()

EF 4 CTP5:

Dim db2 As New ProductContext
Dim db3 As New ProductContext

db2.Product.FirstOrDefault(Function(m) m.ID = 100).Name = "Change1"
db3.Product.FirstOrDefault(Function(m) m.ID = 100).Name = "Change2"

db2.SaveChanges()
db3.SaveChanges()  

These codes are only different in their Contexts. In LINQ to SQL, the second SubmitChanges will rise an exception of “Row not found or changed.”, but in EF it will ignore the changes and continue changing the row twice, which I think is bad because we must consider concurrency, right?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T11:25:45+00:00Added an answer on May 19, 2026 at 11:25 am

    Focusing on your first comparison, I believe that you have some optimistic concurrency checking on by default in LINQ to SQL. IN EF, you have to explicitly mark any properties that you want to be checked for concurrency. Since you most likely have not done that for the Name property, EF doesn’t care that someone changed the Product name in another database command.

    I also want to point out that this isn’t specifcally a code first behavior but it is a behaviour throughout EF. If you create an Entity Data Model, you also have to expclitily mark properties for concurrency checking.

    If you are using the fluent API, look for IsConcurrencyToken as an attribute to set on a property. If you are using annotation, take a look at ConcurrencyCheckAttribute.

    hth
    julie

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is just something that's been puzzling me ever since I read about iterators
Ever since I started programming this has been something I have been curious about.
I just read this article about the Entity Framework 4 (actually version 2). Entity
Ok so I just read this question Do you ever use the volatile keyword
Ever since I created this Rails 3.2.3 project to use MiniTest, I have been
Ever since ereg became depreciated, I began to use preg_match. Unfortunately in my code,
i'm new to this kind of things. Kinda the first post ever regarding programming,
Most code I have ever read uses a int for standard error handling (return
Ever since getting out of college (06) I have primarily worked with java and
In C#/VB.NET/.NET, which loop runs faster, for or foreach ? Ever since I read

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.