asp.net-mvc-3,entity-framework-4,optimistic-concurrencyRelated issues-Collection of common programming errors


  • Davide.77
    asp.net-mvc-3 pdf fonts itextsharp font-face
    I’m not able to find a reason why my MVC 3 web site shows arabic font correctly and my pdf not.I use a bliss font in my web site;@font-face { font-family: ‘blissregular’; src: url(‘/Fonts/blissregular-webfont.eot’); src: url(‘/Fonts/blissregular-webfont.eot?#iefix’) format(’embedded-opentype’),url(‘/Fonts/blissregular-webfont.ttf’) format(‘truetype’); font-weight: normal; font-style: normal;}All working fine. After that I want to create the pdf of the output but arabic fonts does not appears.I’v

  • Jim
    asp.net asp.net-mvc asp.net-mvc-3 asynchronous
    I have a ASP.NET MVC3 application that handles time-consuming processes (copying a large file from network). What we want to do is:User clicks a button to post the form to trigger the process Application starts a new thread to start copying the file Application shows a message saying the file-copying process has begun User can close the browser while the copying processed and finished in the background.The idea is that the user doesn’t need any confirmation on the progress of the process, nor be

  • Kirk
    inversion-of-control asp.net-mvc-3
    We have recently upgraded a project to MVC 3 Tools and discovered that our inversion of control container is causing problems with the native MVC model binding validation on both client- and server-side. When we have the IoC hooked up the client validation fails to fire at all and the “IsValid” test in the controller fires erratically and passes along data when it should not. The only way we’ve been able to correct the validation framework is to disable the IoC completely. We were using Ninject

  • Cameron
    jquery asp.net-mvc-3
    I have the following JS:$(‘form’).live(‘submit’, function (event) {// Stop the form from doing a native postbackevent.preventDefault();$.ajax({type: ‘POST’,timeout: 5000,url: $(this).attr(‘action’),data: $(‘form’).serialize(),success: function (responseHtml) {$.getJSON($(this).attr(‘action’), function (data) {console.log(data);});},error: function (jqXHR, textStatus, errorThrown) {alert(‘server error’);}});});Which should log the json from the following mvc method on fail (note this is a login f

  • CD Smith
    vb.net asp.net-mvc-3 linq-to-sql .net-4.0
    I’ve read through the posts here and can’t find any eureka answers so here’s what I have. Linq to SQl not propagating a change back to the db.Here’s my code. Does anything stand out? The call to dc.GetChangeSet shows 0 changes. What am I missing? I can see the new values from “setting” being set to the cs object properties. SettingID is a primary key in my table and shows as PK in the dbml so that’s not an issue.Public Shared Function Update(ByVal setting As ClarifireSetup) As BooleanDim cs As

  • ekkis
    ajax asp.net-mvc-3 callback razor
    why do I always have so much trouble…? given that I didn’t solve the problem in my other article, I decided to just code the javascript right into the values… so I have:OnSuccess=”alert(‘ok’)”, OnFailure=”alert(‘failed’)”,so my problem is the submission works fine; a record gets inserted into the database and I get a callback… but I get the wrong callback! I get a failure even though the record got inserted. heeeeelp!

  • teahou
    asp.net-mvc-3 validation
    This has been asked and answered 100 times, and I have read them all, yet still my form submits after failing validation. I found a reference to not using jquery.validate higher than 1.9.0, so I rolled back to that (had been using 1.11) but no change.If i submit with an invalid form (nothing filled out) the error messages appear, then the form submits.I have successfully implemented validation a couple times in the past, and I can’t see what is different about this time. I need to take a break

  • Pat James
    asp.net-mvc asp.net-mvc-3 mobile 51degrees
    In my ASP.NET MVC 3 web application I am overriding the View name in a custom view engine to present a different view optimized for non-tablet mobile devices.All I want to perform this view override is an accurate value for Request.Browser.IsMobileDevice and the device’s native display width.51degrees.mobi feels very heavy and convoluted for this simple use case. Maybe that is just my frustration at trying to wade through all of the examples and documentation on the 51degrees web site to get an

  • EH_warch
    asp.net-mvc-3 sql-server-express asp.net-mvc-scaffolding
    I’m creating a new MVC 3 pilot application using Mvc3 and the MvcScaffolding NuGet, everything runs smoothly until i want to use the database i already have. The application keeps creating a database with the format:projectname.Models.projectnameContextI’m stuck in here, my connectionStrings is:<connectionStrings><add name=”ApplicationServices” connectionString=”data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true” providerNam

  • Christofer Eliasson
    c# asp.net-mvc-3 version-control entity-framework-4.3 ef-migrations
    I have an ASP.NET MVC3 project that uses Entity Framework 4.3 with the code-first approach. I use Migrations to keep the database up-to-date.The project is under source-control and I have a number of branches. What I just realized is that there will be a problem when I wan’t to merge one of my branches into the master. Since I have created migration-files in both branches, there will be overlapping migrations when I merge, which will probably cause conflicts.Is there a good way to manage Migrat

  • Colin Desmond
    asp.net-mvc-3 entity-framework-4 optimistic-concurrency
    We have an ASP.Net MVC application that uses EF4 as its data access layer and we’re seeing unexpected behaviour with regards to OptimisitcConcurrencyExceptions not being thrown when we think they should be.We have simplified the problem down to the following code…using System.Linq;using Project.Model;namespace OptimisticConcurrency{class Program{static void Main(){Contact firstContact = null;using (var firstEntities = new ProjectEntities()){firstContact = (from c in firstEntities.Contacts wher

  • Dani
    entity-framework-4
    I have an entity with a collection of related entities.I create a new entity with the same key, and new related entities (collection).I’ve added the ned related entities to the collection of the main entity and now I want to save everything to the DB.I’ve found the old entity and it’s collection and detached everything. than i’ve attached the new entity and in foreach loop – all the related entities in the collection.when I commit – context.SaveChanges() I get OptimisticCuncurrencyException Sto

  • Andy Clarke
    entity-framework entity-framework-4 ef-code-first
    I’m having a problem with the Entity Framework (EF4.1 – CodeFirst)It’s basically duplicating child objects …The object model is a number of Tasks within a Job -> the Task has a TaskType and that TaskType has a number of Statuses …At first it was duplicating TaskTypes on a save However, after I added this it stopped duplicating the TaskTypes …context.Entry(task.TaskType).State = EntityState.Unchanged;So I tried this for the statuses …//tried this but it errorsforeach (var status in task.T

  • SamJolly
    asp.net-mvc asp.net-mvc-3 entity-framework entity-framework-4 entity-framework-5
    I have a 2 project MVC3 .NET 4, EF5 Web Application which I have just tried to “One-Click” Publish to my DiscountASP account which has a MS SQL Server 2008 instance installed.The error I am getting is :Schema specified is not valid. Errors:OrdersDB.csdl(2,9) : warning 0005: Could not find schema information for the attribute ‘Namespace’.OrdersDB.csdl(2,38) : warning 0005: Could not find schema information for the attribute ‘Alias’.OrdersDB.csdl(2,288) : error 0005: The ‘http://schemas.

  • wishper
    c# entity-framework-4 transactions oracle11g
    I trying to understand how I can make transactions work with my project. I use EntityFramework 4 with an Oracle 11g database.Here his the deal, I have a lot of operation to do, and I want to roll back when an unexpected exception is thrown. I have multiple class with simples operation, each class create it’s own Context and make some change, for example :public class OneDaoFactory {public int AddTreatment(Dto dto){using (Context bdd = new Context()){//Make some changes in databasebdd.SaveChanges

  • gdubs
    asp.net entity-framework entity-framework-4 concurrency webforms
    I’m having problems with doing a concurrency exception whenever I do an Object on my contextI have this: (I’m using it on webforms btw)using(entities ctx = new entities()){EventModel newEvent = new EventModel{Name = “name”,Description = “description”,CreationDate = DateTime.Now,CreatedBy = CurrentUserId()};try{ctx.EventModels.AddObject(newEvent);ctx.SaveChanges();}catch(OptimisticConcurrencyException ocex){if(ctx.ObjectStateManager.GetObjectStateEntry(newEvent).State == EntityState.Added){// pro

  • RPM1984
    asp.net entity-framework entity-framework-4 optimistic-concurrency
    I’m using Mssql as the db and EF4 as the ORM/DAL. My question is about the following code:public static void DeleteBuilding(int buildingId, int countryId) {PlayerBuilding playerBuilding = new PlayerBuilding(){CountryID = countryId,BuildingID = buildingId};Entities.PlayerBuildings.Attach(playerBuilding);Entities.PlayerBuildings.DeleteObject(playerBuilding);Entities.SaveChanges(); }If the row exists this works very well, if not I get an exception(Store update, insert, or delete statement affected

  • Patrick Desjardins
    c# entity-framework entity-framework-4
    I have a situation where I have an object that is loaded back from a form to MVC controller via an action. We do not use FormCollection, but the one that use directly the class.[HttpPost]public ActionResult AjaxUpdate(Customer customer) { …The Customer object contain an object called customer which seem to be updated but when using SaveDatabase() on the context simply doesn’t work.To make it works I had to use in the action:myDbContext.Customers.Attach(customer) //…Code here that set to the

  • Eric Sassaman
    asp.net entity-framework-4 linq-to-entities
    I have an Entity Framework 4 design that allows referenced tables to be deleted (no cascade delete) without modifying the entities pointing to them. So for example entity A has a foreign key reference to entity B in the ID field. B can be deleted (and there are no FK constraints in the database to stop that), so if I look at A.B.ID it is always a valid field (since all this does is return the ID field in A) even if there is no record B with that ID due to a previous deletion. This is by design,

  • Only Bolivian Here
    sql-server tsql entity-framework-4
    Imagine this setup:create table ObservationType ( ObservationTypeId int primary key identity(1,1), Name nvarchar(32) not null )create table Observation ( ObservationId int primary key identity(1,1), ObservationTypeId int foreign key references ObservationType(ObservationTypeId), Title nvarchar(32) not null, Description nvarchar(1024) not null, StudentId int foreign key references Student(StudentId) )create table Student (foo bar )Now imagine this is full of data, it’s working fine. How do you d

  • Colin Desmond
    asp.net-mvc-3 entity-framework-4 optimistic-concurrency
    We have an ASP.Net MVC application that uses EF4 as its data access layer and we’re seeing unexpected behaviour with regards to OptimisitcConcurrencyExceptions not being thrown when we think they should be.We have simplified the problem down to the following code…using System.Linq;using Project.Model;namespace OptimisticConcurrency{class Program{static void Main(){Contact firstContact = null;using (var firstEntities = new ProjectEntities()){firstContact = (from c in firstEntities.Contacts wher

  • SimpleUser
    mysql asp.net-mvc-3 optimistic-concurrency
    I’m trying to get my MVC3 application to use MySql database instead of Sql Server 2008. I have created the associated database and objects in Mysql. And Updated the connection string in my web.config file to reference MySql.Data.MySqlClient. When I run my application and try to login, I am getting the errorStore update, insert, or delete statement affected an unexpected number of rows (0). Entities may have been modified or deleted since entities were loaded. Refresh ObjectStateManager entrie

  • RPM1984
    asp.net entity-framework entity-framework-4 optimistic-concurrency
    I’m using Mssql as the db and EF4 as the ORM/DAL. My question is about the following code:public static void DeleteBuilding(int buildingId, int countryId) {PlayerBuilding playerBuilding = new PlayerBuilding(){CountryID = countryId,BuildingID = buildingId};Entities.PlayerBuildings.Attach(playerBuilding);Entities.PlayerBuildings.DeleteObject(playerBuilding);Entities.SaveChanges(); }If the row exists this works very well, if not I get an exception(Store update, insert, or delete statement affected

  • icrf
    asp.net sql-server asp.net-mvc optimistic-concurrency providers
    I’m using the new Universal Providers from Microsoft for session in SQL Server. The old implementation of session on SQL Server required a job (running every minute) to clear expired sessions. The new one does this check and clear on every request. Since I’m actually running in SQL Azure, I don’t have SQL Agent to schedule jobs, so this sounds like a reasonable way to go about it (no, I don’t want to pay for Azure Cache for session).The problem is when multiple users access the site at the same

  • svick
    c# dataset optimistic-concurrency
    I try to update a field of my object, and save it right away to the database.using (var ctx = new DataModel(_connectionString)) {var MyObject it = ctx.MyObjects.Where(someConstraint).ToList()[0];try{//update check timectx.Refresh(RefreshMode.StoreWins, it); //making sure I have itctx.AcceptAllChanges(); // in case something else modified it – seems unnecessaryit.TimeProperty= DateTime.UtcNow; //Setting the fieldctx.DetectChanges(); //seems unnecessaryctx.SaveChanges(SaveOptions.AcceptAllChangesA

  • Adam Wagner
    insert linq-to-entities optimistic-concurrency
    Hi I’m having trouble solving this error. Any help on the problem would be much appreciated, thanks!Error message:Store update, insert, or delete statement affected an unexpected number of rows (0). Entities may have been modified or deleted since entities were loaded. Refresh ObjectStateManager entries.Whenever I try to add a Laptop/Desktop, I get the above error message. Everything works fine when running locally, but not on dev. The website and service/database are on two different dev boxe

Web site is in building