How to upgrade Linq to SQL dbml file from old version of VS? - linq-to-sql

I opened an old project, and I can't open the dbml file.
For some reason I get "Cannot load.. check Error List window for details".
But, there aren't any errors.
I can create new dbml file, so there is no problem in the viewer itself.
Is there a known issue?

The first thing I would check is the connection string of the dbml file, which you can find in the FileName.designer.cs (or could be .vb instead of .cs) file that is attached to the FileName.dbml file.
If you say you can create a new dbml file, then it is possible that the old dbml file has an outdated connection string.

Related

Using dbml file with visual studio

I am developing an asp.net application where some dbml files have been created. When I click on a dbml file called "Test.dbml" and that I unfold it, I get the three following files :
Test.cs
Test.dbml.layout
Test.designer.cs
However when I create a new dbml file and that I unfold it, I only get the two following files :
Me.dbml.layout
Me.designer.cs
I don't understand why I don't get the Me.cs like the existing dbml.
I only have access to the old code, not to the developper who code it so I cannot ask him the question.
Thanks in advance foryour help.
By default VS generates a .dbml.layout (visual layout) and .designer.cs (C# generated code) in addition to the .dbml file (XML definition of the mappings)
If you were to put your code in the .designer.cs file it would get lost so VS can also generate a .cs file for you to put your code in.
Simply right-click on the DBML and choose View Code.
At compile time the .cs and .designer.cs are effectively merged together as they are partial classes (the partial keyword needs to be on the class definitions)

The connection "C:\\<path>\\*.txt" is not found. This error is thrown by Connections collection when the specific conn element is not found

I developed a SSIS package that creates several .txt files. These files are zipped and then the .txt files need to be removed. Using a foreach file enumerator, I loop through all the .txt files for a specific folder. The folder is retrieved from a variable in configuration and looks something like: C:\Folder\
The foreach loop uses: *.txt to gather all .txt files, does not traverse subfolder and uses the full qualified name.
In the Variable Mappings the "FileName" variable gets filled with the 0 index.
Within the foreachloop I use a File system task.
This task removes the .txt files which are generated before, using the FileName variable that is filled in the loop.
On the development machine this runs like a charm. All greens, no problem at all. Now I copy the package and the configuration file to the test environment. A basic version without the file removing was running perfectly fine here. I replaced the package. Nothing big.
Now I run the SQl Server Agent Job and it starts running. I can see all the text files appearing, and disappearing after it created the zipfiles. However, when all files are removed the package results with errors. Namely the error shown above in the title.
I tried looking for the connectionmanager that might have been removed
Looked for connection managers named in the config that don't exist in the package.
No such thing found. Annoying part is that the package is fully functioning, but still results with the error.
EDIT: I noticed that if I run the package using the execute package utility with the dev. config it gives the same errors.
Hopefully someone is able to help me out.
Thanks in advance!
I managed to "fix" the issue. Remove the File System Component responsible for deleting the files. Then add it again and configure it again.
I think this happens if you accidentally change General parameters before changing the Operation parameter. It holds the metadata to irrelevant parameters and upon execution says: "Wait, you defined this parameter but I don't need it, but I'm checking for it anyway, and it's not there!"
It's a bug for sure

Adding column manually to table in dbml file

I manually added a column to a table in a .dbml file by editing the xml.
Hereafter I rigthclicked the .dbml and chose 'Run Custom Tool'.
I'm new to linq-to-sql and is working on an existing MVC webapp with domainmodel and viewmodel.
The solution also contains a database project which I know was not updated automatically.
Now I need to know how to check that everything was updated correctly. Is it only the .dbml and the .designer.cs that I can expect to be changed after running the custom tool?
'Run Custom Tool' does the trick. Nothing else is needed.
And no other files than .dbml and the .designer.cs files are changed.

How to change the flatfile connection manager "file name" value in SSIS package?

I have an ssis package...which read data from fixed-column-width text file into DB table.
And I am modifying an existing ssis package.
I have a flat file source...and flat file cnnection. When I try to edit the flat file connection...using "flat file connection manager editor"..., under "general" part...even if I select different filename..it's not getting reflected.
OR...select the properties window of "Flat File Connection" - once I change connection string and click "save" of visual studio...it rollback
Help me please.
Pulling a useful comment into an answer...
It's possible that that Connection string (the file path, name) is set from an expression/user or project parameter.
To check, right-click the flat-file connection manager and go to Properties, then check Expressions to see if the ConnectionString is set from a variable such as #[User::MyFileConnectionString]
That would cause this behavior of it seemingly "un-doing" after you change it manually.
Is it possible you don't have access to the package itself? Right clicking on the file icon in the Connection Manager below and selecting 'Rename' and then renaming it right there and then saving the package should work.

importing a pre-existing edmx file is a new vs 2010 solution

Hi I started from scrath a new vs 2010 solution.
How can I add a preexisting edmx file generated with the vs tool avoiding mess :)? (The cleanest way)
Thanks a lot!!
I am quite sure that adding the edmx file as an existing Item will work quite well. You will have to add the adequate connectionString in your config file however.
<add name="<EntityContainerName>" connectionString="metadata=res://*/<pathToEDMX>.csdl|res://*/<pathToEDMX>.ssdl|res://*/<pathToEDMX>.msl;provider=System.Data.SqlClient;provider connection string="Data Source=localhost;Initial Catalog=MyDatabase;Integrated Security=True;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient" />
where pathToEDMX is the path to your edmx file in the project (for exemple Models.Model if you included the Model.edmx file in the Models directory of your project)
You will want to change the database connection string in this mmodel connection string too.
In order for this connecion string to work, the model option "Metadata Artifact Processing" must be set to "Embed in Output Assembly"
I agree with the Eilistraee, But I have another openion which is very much procedural. you can add this existing edmx file to your project. then you can open the edmx file and create database from this model(this can be done by right clicking on the entity diagram. ), when you select the proper database, it will automatically create the connection string in your app.config. Good luck.
If you want to do this, the way I found to do this is:
Open the solution that the contains the project you wish to import into.
Add the project that contains the edmx you want to import.
Copy and paste the edmx file from one project to the other.
Remove the second project and proceed.
This might be necessary: Open the edmx, adjust namespace, etc and save it.
VS 2013 and EF 6.1