Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting Error 3007 when I add my Entity Model

I am getting an error 3007 when I add my entity model to my solution.

I found these links:

Good explination

Short answer

About this error:

Error 1 Error 3007: Problem in Mapping Fragments starting at lines 89, 94: Non-Primary-Key column(s) [Person_ID] are being mapped in both fragments to different conceptual side properties - data inconsistency is possible because the corresponding conceptual side properties can be independently modified.

Their Answer: I agree with their conclusion that by simply deleting the Scalar Property Person_ID and leave the Navigation Property my problem is fixed. However this is not very scalable since I am dynamically building my database and my entity is updated very often. I dont want to have to go through and clean up my entity every time I update it.

My Question: Is there a way to fix the error by correcting the way EF builds the entity? Or is there a way to remove the Scalar Property through code? Perhaps there is even a few options that I am overlooking.

like image 581
johnnywhoop Avatar asked Sep 02 '09 19:09

johnnywhoop


People also ask

How to fix event ID 3007 3006 and 10021?

Event ID Error 3007, 3006, and 10021 I've been getting this error every time I start up my computer. Now the things is, the usual fix for this is to uncheck windows search at the "Turn on or off Windows Feature" then recheck. However,

How do I fix error code 3007 on Windows 10?

I've been getting this error every time I start up my computer. Now the things is, the usual fix for this is to uncheck windows search at the "Turn on or off Windows Feature" then recheck. However Event ID Error 3007, 3006, and 10021

Why can't I transfer entity with added state to database?

So for an entity with Added state, the key column will be ignored and not be transferred to the database. This explains why the error is about a NULL value for a property that's not even nullable in code.


Video Answer


1 Answers

Try to remove foreign property column from Entity set using entity model design it will solve your problem

For example

We have two tables one is customer and other one is order, using entity model design we added association between customers and orders when we do this Ado.net entity framework i will add navigation properties to both below tables.

Like Customer.Orders - Here order is list Order.Customer

One - Many relation.

So we need to remove property from with name CustomerId[Foreign key column] from Order entity set.

For reference:

http://social.msdn.microsoft.com/forums/en-US/adodotnetentityframework/thread/2823634f-9dd1-4547-93b5-17bb8a882ac2/

like image 129
Venkat Avatar answered Oct 21 '22 19:10

Venkat