开发者

Problems with Entity Framework Model when Transactional Replication active

开发者 https://www.devze.com 2023-02-27 01:23 出处:网络
I have a situation where I use SQL server transactional replication from my main database 开发者_如何学Pythonto my failover database. I have a main site and my fail over website is using my failover d

I have a situation where I use SQL server transactional replication from my main database 开发者_如何学Pythonto my failover database. I have a main site and my fail over website is using my failover database.

Both websites (use entity framework) are identical (so are databases hopefully).

My problem is that some operations crash on my failover website if my replication is active. Once I deactivate my replication, the operation goes through normally.

My guess is there is some concurrency issue between the EntityModel of my fail over website and the database when exposed to replication.

Has anyone encountered similar issues? Anyone with experience with transactional replication + entity framework ?

Here is the exception I get:

at System.Data.Mapping.Update.Internal.UpdateTranslator.Update(IEntityStateManager stateManager, IEntityAdapter adapter) 
at System.Data.EntityClient.EntityAdapter.Update(IEntityStateManager entityCache) 
at System.Data.Objects.ObjectContext.SaveChanges(SaveOptions options) 
at System.Data.Objects.ObjectContext.SaveChanges() 
at Library.XXXXEntities.Context_SavingChanges(Object sender, EventArgs e) 
in C:\SVN\Branches\Prod - 1.68.7\Library\LINQ\Audit.cs:line 38 
at System.Data.Objects.ObjectContext.OnSavingChanges() 
at System.Data.Objects.ObjectContext.SaveChanges(SaveOptions options) 
at System.Data.Objects.ObjectContext.SaveChanges() at Library.Provider.Save() 
in C:\SVN\Branches\Prod - 1.68.7\Library\XXXX.Provider.cs:line 57 
at XXXX.mnuExportGeneric.RecreatePositionsToBeUnique() 
at XXXX.mnuExportGeneric.Export(Int32 programId, DirectoryInfo directoryDestination, Boolean exportInventory, Int32 CurrencyListID, Int32 configurationId, Boolean subFolder) 
at XXXX.mnuExport.Export(Int32 ProgramId, String TempExportFolder, String ExportFolder, TreeView treeViewErreurs, Int32 CurrencyListID, Boolean exportInventory, Int32[] configurationsId) 

There seams to be a problem with the mapping, but only when the transactional replication is active.

Update: I've come out completely of my application environnement and simply trying to insert a new row in a table in my failover database when the replication is "existing" not just active seams to be illegal. Tomorow I'll try with the replication completely removed... or more drastic changes like that...

Thanks!


This is probably not a problem with EF but more a problem with your replication setup.

SQL Server does allow for replications where changes can be made at any node, but this requires enterprise edition, see: http://technet.microsoft.com/en-us/library/ms151196.aspx

It may be that you are trying to update a readonly replica.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号