Question

I'm having some trouble trying to [INSERT/UPDATE] records in our database since we have implemented a replication scenario. (SQL SERVER 2012)

When I try to save an entity I get these messages:

Updating columns with the rowguidcol property is not allowed.

The transaction ended in the trigger. The batch has been aborted.

Sometimes this one

Cannot insert duplicate key row in object 'dbo.Job' with unique index 'MSmerge_index_1345596032'. The duplicate key value is (00000000-0000-0000-0000-000000000000).

I'm a bit lost as to how to generate the edmx model, without it having the rowguid being in the Entities.

The pattern I use to save

        var entry = db.Entry(job);

        entry.State = (job.JobId == 0) ? EntityState.Added : EntityState.Modified;
        db.SaveChanges();

        return entry.Entity.JobId;

How do I use Ef and replication without going crazy with the rowguid?

UPDATE:

I have set in the modal browser the rowguid property of StoreGeneratedPattern to Identity, it seems to working again, but I don't know the impact of doing it that way.

What is the best way to deal with Replication with EF??

Was it helpful?

Solution

Your development database must not be configured for replication scenarios, you should be able to map your database without rowguid columns, ask for a database backup to the DBA and then restore it without preserve the replication settings. Check this link: Entity Framework update table with rowguid

OTHER TIPS

try to change your model diagram (.edmx), where you have to change the StoreGeneratedPattern property from "None" to "Computed".

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top