ASP.NET Entity Platform Dynamic Data: Many For Many Insert The Difference On The Server

I created a simple ASP.NET Dynamic Data application and it works fine on my development machine. When I deploy it, everything works fine, except for the insert page for an element that has many-to-many relationships to other tables. Editing the page is in order, many-to-many checkboxes appear. The server has .NET 4.0 installed.

I followed the instructions below: http://go.microsoft.com/fwlink/?LinkId=257395

Anyone have an idea what the problem is?

+4
source share
3 answers

I am not 100% sure, but I think that the versions of System.Web.DynamicData.dll and System.Web.DynamicData.Design.dll were different on my development machine and on the server, so you may need to double check this. I also remember that I had to set up primary keys for all relationship tables, but this may be a separate question ... This will teach me to answer my question when I find a solution ...

0
source

@TimS: can it help if you can add additional information about your situation - does this also work for you in one environment and not in another? Do you know the versions of all installed components in both environments?

The first two places I would see if I understood the question correctly:

  • Assuming you have some kind of automatic mapping from form to entity / model, do you need to initialize the entity or model with default values ​​before loading the insert page?

  • Is your database the same in both settings - with the same keys defined (I assume the code is identical ...)

0
source
  • Ensure that the many-to-many table contains a primary key that consists of the primary keys of two related tables.

  • Make sure that the table is displayed in EDMX as a table, and not in a view (especially if you use DB-first and you need to fix point 1).

  • If you use POCOs, make sure that the relationship properties (and other properties) are public or secure and are virtual.

  • If you use POCOs, be sure to fix the other side of the on-change relationship (default in POCO-T4).

  • If you establish a relationship using two objects, for example. a and b

    using:
    a.Bs.Add(b);

    Then, if a was created as a proxy, for example,
    a = context.As.CreateObject();

    instead:
    a = new A();

    EF will make it easier to identify changes.

    Alternatively, if you use an ObjectContext , you can call
    context.SaveChanges(SaveOptions.DetectChangesBeforeSave | SaveOptions.AcceptAllChangesAfterSave);
    to help EF find the changes.

0
source

Source: https://habr.com/ru/post/1435534/


All Articles