Entity Framework 4 displays fragment error when adding a new scalar object

I have the design of the first Entity Framework 4 model. I create the first project of my model in the designer, and everything was fine. I compiled, generated a database, etc.

Subsequently, I tried to add a string scalar (Nullable = true) to one of my existing entities, and I continue to get this type of error when compiling:

Error 3004: display problem fragments starting at line 569: No mapping specified for the MyEntity.MyValue properties in Set MyEntities. Key Object (PK) will not be round-trip when: Entity type [MyEntities.MyEntity]

I need to manually open the EDMX file and fix the XML whenever I add scalars.

Ideas about what's going on?

+63
entity-framework entity-framework-4
Jun 08 '10 at 23:26
source share
8 answers

Since then, I have found that after adding / changing / deleting properties on my objects, I have to “Generate a database from the model” before compiling, otherwise I get 3004 matching errors.

+73
Jun 09 2018-10-06T00:
source share

I just deleted the breaking tables from the model and then added them back, and everything was fine.

+38
Jun 24. 2018-11-11T00:
source share

For those of you who are creating a model from a database, I came across this problem after I made changes to my database. This happened when I changed the name of the field in the database for one reason or another (I think this will also happen if you change the data type).

The solution for me was to right-click on the workspace and select "Update Model from Database". This should add properties from the database to your model, however it will NOT remove your old properties, and this will give you error 3004.

Right-click on the workspace and select Confirm. This should give you a list of bugs showing offensive features. You can then right-click each offending property and manually remove it from your model.

This solved the problem for me. Hope this helps someone else.

+26
Aug 14 2018-12-12T00:
source share

If you want to change your database without regenerating the entire model or re-creating your database from the model, I consider it the easiest and safest way to change the properties of an EDMX diagram using Visual Studio, and then manually adjust the mappings that visual studio doesn't give access.

The error will give you the line number:

Problem displaying fragments starting at line 569

Just open the edmx file in a text editor, go to that line, and it should be pretty obvious what you need to fix it. There will be a section that will look like this:

<EntityTypeMapping TypeName="YourModel.YourType"> <MappingFragment StoreEntitySet="YourType"> <ScalarProperty Name="PropertyName1" ColumnName="DatabaseColumn1" /> <ScalarProperty Name="PropertyName2" ColumnName="DatabaseColumn2" /> ... </MappingFragment> </EntityTypeMapping> 

Just make sure that there is a node for each property / column name, and that all properties are also listed in the <EntityType Name="YourTable"> section at the top of the edmx document

+9
Apr 23 '13 at 16:33
source share

If all your queries are written in stored procedures, and you are just trying to populate the model, you can switch to the complex type that worked for me.

How to create a complex type:

  • Manually change the name The created Entity class having problems with the name is not already used in your edmx file.
  • Select the model browser window and right-click / add a new complex type.
  • Copy / Paste the properties of the original model to a complex type.
  • Match stored procedures to complex type.

    I hope this helps someone.

+1
Feb 09 '11 at 15:37
source share

I got the same problem after renaming a property on one of my objects.

I found out that the comparison between the property of my entity and the corresponding column in the table has not been established.

You can set this using the editor by right-clicking on an object in the model and selecting "Display Table". Verify that the properties are mapped to a column in the database.

Edit: I also needed to restart my tt file to create new classes. (Perhaps since I have this in another project?)

0
Feb 17 '13 at 9:44
source share

After viewing the xml (edmx) file, move the model to another project and understand that everything is in order, I decided to close and open Visual Studio and compile again, then the error will disappear.

0
Mar 13 '13 at 21:13
source share

Another alternative for this, without removing the table from the chart and re-adding it, is to use the table matching function.

  • Go to model browser
  • Right-click the table name.
  • Select tab display
  • Visual Studio will display a window with EF properties matching the / missing columns of the table.
  • Select / match the corresponding column with the missing property

enter image description here

0
Feb 05 '16 at 6:40
source share



All Articles