Link to home
Start Free TrialLog in
Avatar of Kaprice
KapriceFlag for United States of America

asked on

Error deleting field in Visual Studio 2013 mdf

I created a Linq to Sql class and an dbml from a LocalDB mdf.

I want to delete a field from the database.

I get this error:

Update cannot proceed due to validation errors.  
Please correct the following errors and try again.

SQL71501 :: Index: [dbo].[MemberPanTickets].[MemberPanTickets$Identifiers] has an unresolved reference to Column [dbo].[MemberPanTickets].[Location].

The field is a text field. Is not part of any relationships. But, does have an index. I get the same error when only trying to delete the index.

I've deleted the field from the dbml diagram but still get the error.

How do I find and remove the reference that's causing this error?
Avatar of Randy Downs
Randy Downs
Flag of United States of America image

Try this.

right click on the DB project in VS you get the 'Publish Database' dialog. You setup the target server connection and choose the correct database.

Then click on the 'Advanced...' button to open up the 'Advanced Publish Settings'.

1) Uncheck - 'Block incremental deployment if data loss might occur' checkbox.
2) Check - 'DROP objects in target but not in project'

Open in new window

LINQ to SQL is a dying breed.  I found myself deleting the DBML, and recreating it again.  You should look at Entity Framework 6, because it is a living system, and a more mature product.
Avatar of Kaprice

ASKER

Thanks for the tip on EF, Bob. I was really tempted to go that way, but I'm still new to VS and read that EF is more complicated than LinqToSql and since this is a fairly simple data structure, I wanted to reduce the amount of new stuff I had to learn. But, it's good to know that LinqToSql is outdated. I'll focus on EF for my next project.
Avatar of Kaprice

ASKER

Randy, I'll give that a try and report back. Thanks for the tip.
Avatar of Kaprice

ASKER

Randy, I've gone through the thread you linked to and I'm confused.

It appears this process creates a script for creating a copy of the database. Is that right? How does that help me drop a field? And, what do I do with the script once it's generated?
Avatar of Kaprice

ASKER

Bob, are you certain my error is due to dbml?
I am not 100% certain, but it feels like there is a mess of plumbing that is generated, that you would need to find.  If you have heavily customized the data context, then I don't think that you would want to re-generate.  

One suggestion would be to backup all the files related to the DBML file, delete them, and then re-generate.
Avatar of Kaprice

ASKER

Bob, I get the error when trying to drop a field from the database (LocalDB). You're saying the error is because my dbml has a reference that's blocking VS from processing it?
No, I thought you had an error with the data context for LINQ to SQL, not the local database.  Are you trying to use Code First with LINQ to SQL (from Entity Framework)?

If not, what are you using to delete the column from the table?
Avatar of Kaprice

ASKER

No, not Code First.

I'm using Visual Studio Data Connections in Server Explorer.
OK, is the column that you need to delete part of a relationship?  If so, then you need to delete that relationship first.
Avatar of Kaprice

ASKER

I appreciate your help, but if you'll re-read my OP, you'll get a better understanding of the situation.
Heck, that misunderstanding happens after answering so many questions...

I have no idea why this is happening, but I am willing to help you find a solution.  What is the order of operations for the delete?  Are you deleting the index, before the column?
ASKER CERTIFIED SOLUTION
Avatar of Kaprice
Kaprice
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I would suggest marking your own comment as the correct answer.
Avatar of Kaprice

ASKER

Thanks again for all your efforts.
Avatar of Kaprice

ASKER

Solution found and listed.