.NET: Entity Framework: re-add a deleted table resolved!

First of all: for those who think that there is an easy solution. I’m sorry, there is not.

The problem is located in the .edmx file, and not in the designer.cs file as I suspected first.

When you add an .edmx and take a look at it with notepad you’ll see this:



	
	
		
		
			
				
				
			
		
		
		
			
				
				
			
		
		
		
			
				
				
			
		
	
	
	
		
			
				
			
		
		
			
				
			
		
		
		
			
			
		
	

Now you add a table:



	
	
		
		
			
				
					
				
				
					
						
					
					
					
					
				
			
		
		
		
			
				
					
				
				
					
						
					
					
					
					
				
			
		
		
		
			
				
					
						
							
								
								
								
							
						
					
				
			
		
	
	
	
		
			
				
			
		
		
			
				
			
		
		
		
			
				
			
		
	

As you can see I’ve added a table ‘Users’ with ‘UserID’, ‘Name’ and ‘Birthday’.

You can also see the difference between the 2.

Now when you delete the table again from the design surface this is what ‘junk’ that stays behind:



	
	
		
		
			
				
					
				
				
					
						
					
					
					
					
				
			
		
		
		
			
				
				
			
		
		
		
			
				
				
			
		
	
	
	
		
			
				
			
		
		
			
				
			
		
		
		
			
			
		
	

As you can see lines 9 and 12-17 weren’t there in the original -empty- model. You’ll need to clean those up manually.

diff

Removing those lines will give you the possibility to re-add your previously deleted table.