English 中文(简体)
这一实体框架例外的含义是什么?
原标题:What is the meaning of this Entity Framework exception?

这一例外的含义是什么? 在什么地方,我可以找到这种例外的理由?

The changes to the database were committed successfully, but an error occurred while updating the object context. The ObjectContext might be in an inconsistent state. Inner exception message: Metadata information for the relationship MyModel.FK_T_WORKER_VEHICLE_T_VEHICLE could not be retrieved. If mapping attributes are used, make sure that the EdmRelationshipAttribute for the relationship has been defined in the assembly. When using convention-based mapping, metadata information for relationships between detached entities cannot be determined. Parameter name: relationshipName

I am using edmx with code generation set to Default. The pocos are in different project then the edmx file.

问题回答

In my case, I got same error when I added a new entity(A) to my EDMX diagram which A has Foreign key reference to an existing entity B. Then this error came up when I tried to do CRUD for B. I did some researches and followed a tip on MetadataException when using Entity Framework Entity Connection which advises to rename metadata in Connection String but it didn t work for me.

Steps to resolve: The issue was in entity A not B. You need to check newly added entity A to be mapped correctly to your class A in your domain. Check property names and property types to be same (i.e. a column might need to be converted to an Enum type in your diagram to be same with your entity). Keep in mind that property names are case sensitive so if they are in upper-case in your entity it should be in upper-case in your diagram.





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签