I'm having a bit of an issue with EF6 in VS2013. I had to modify the connection string for the database-first model in a Web Application project so I followed the advice in the best answer for How should I edit an Entity Framework connection string? and deleted it from my Web.Config file.
At first it seemed to work fine, I deleted the connection string then from the Entity Designer I ran "Update Model from Database", re-created the connection string, but then my build failed with multiple errors similar to:
Public Sub New() has multiple definitions with identical signatures
After some digging I figured out that when I re-created the connection string EF created a second Model.Context.vb file named Model.Context1.vb and both are still referenced somewhere. Since then I've opened every file in the folder containing my EF model with notepad searching for a reference to Context.vb or Context1.vb and have come up empty, if I remove either file my build fails stating the file can not be found, so as a workaround I opened the Context.vb file and removed all the code so there are no duplicates, I'd like to fix it properly by removing the reference to the file deleting it if anyone knows how I can go about doing that.
I got it sorted out, after attempting to restore an older version of the EF files from source control and still running into the same issue, I realized the reference was probably in a project file.
In [projectName].vbproj I found these two entries:
<Compile Include="Data\schedulerModel.Context1.vb">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>schedulerModel.Context.tt</DependentUpon>
</Compile>
<Content Include="Data\schedulerModel.Context.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<DependentUpon>schedulerModel.edmx</DependentUpon>
<LastGenOutput>schedulerModel.Context1.vb</LastGenOutput>
</Content>
I removed the first, and dropped the 1 from the context.vb file in the second, opened the project and ran a rebuild without issue.
I had the same problem but a slightly different resolution. For whatever reason, updating the edmx file one time seemed to remove a seemingly important line from the project file, the line reading <LastGenOutput>MyEntityModel.Context.cs</LastGenOutput>.
I re-added the line to my project file and updating the model didn't result in any more duplicate context files. The whole block looked like the following when fixed:
<Content Include="MyEntityModel.Context.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<DependentUpon>MyEntityModel.edmx</DependentUpon
<LastGenOutput>MyEntityModel.Context.cs</LastGenOutput>
</Content>
Just thought I'd add my findings to this as it has been driving me to distraction for a few weeks - every time I updated my Model from Database, I got "duplicate" context, designer files etc, and then hundreds of errors. However, the new sp or table or whatever I had added was only present in the new "context1" files, not the originals, so when I wound it back I had to go through the same process again etc etc.
Then finally a light went on when I thought of ... Source Control! I use TFS, and I found that unless ALL model-related files are checked out before doing the Update, so that's Context, Designer and Service files, then EF generates new versions of almost everything, presumably because it can't modify one of the files which are read-only due to source-control.
The key then is to fix the project file as stated in answers above before getting everything checked out and THEN doing the update. If you don't get that tag right in the proj file, it goes and does it all wrong again even though everything is checked out.
Hope this helps - my sanity is slowly returning anyway.
Ade
Related
I have an c# wpf application and an additional installer project to create an installer of the application. Among many other files, the installer project has a installer.cmd file (I took over it from someone else) and a Product.wxs file. I was able to create an installer by running msbuild tools\installer.cmd /P:Library=net461 /P:Platform=x64 command on the developper comand prompt.
I was trying to create a desktop shortcut in all user's desktops and was playing with *.wxs file for that. I know you guys will roast me because of the following sentence but I don't know what else can I say. Something I did break something and somehow the msbuild starts to give error. I cannot say what I did because I tried many different things.. I went back to original project but it didn't help. So what is done is done. I will talk about the error now.
The error itself doesn't tell much:
C:\workspace\QToolInstaller\tools\installer.cmd(117,5): error MSB3073: The command "nuget Source Add -Name PkgSrc_638107674121812897 -Source C:\workspace\QToolInstaller\exports" exited with code 1.
I checked online to understand this error code but there wasn't much. However there is another line just before this erorr line:
The source specified has already been added to the list of available package sources. Provide a unique source.
Well, this wasn't in usual warning color or marked as a warning. But I think it is worth to investigate.
So the "source" mentioned here is PkgSrc_638107674121812897. I scanned the installer.cmd to see where is this coming form and saw that this file is named by using time ticks as:
<LocalSource>PkgSrc_$([System.DateTime]::UtcNow.Ticks)</LocalSource>
Although I ran the msbuild command multiple times, the name of the source is always different. I ran the command in diagnostic mode by using -verbosity:diag option. And I checked the file name among all the logs. There is no match. I tried to change the name to something ridicolous that cannot be listed anywhere but got the same error. Removed alll the files, created them again, restarted the PC etc. Nothing have changed. This name is really unique and but still I am getting this message. I wish I had logs form previous successfull runs. I cannot tell if this is the cause of the failure or not. Does any of these ring any bell fellas?
It is solved! Luckily a colleague of mine have faced with this before. I hope no one will have to deal with this problem again.
So apparently there is a bug(?). Altought that name is unique it thinks the opposite. When I do list the sources with thw followng command
nuget source
among the one that should be there, there is one extra line as PkgSrc_638107643440982987. Although my installer.cmd suppose to remove the source every time after it is done, it didn't for once. And although the new source is named differently, it doesn't care and gives that non-warning, non-error message followed by a meaningless error code 1 message. How to solve it?
We tried to remove the source by command prompt like this:
nuget source delete -Name PkgSrc_638107643440982987
But it is not deleted. So we went to the Visual Studio->Tools->NuGet Package Manager->Package Manager Settings->Package Sources. Found the guilty source and remove it. And then it is resolved.
I don't know what to say, nor what additional details to provide. My entire code is gone, my entire project, my entire work. I have nothing to paste because everything is deleted.
Can someone tell me how I can discern what the f*** is happening?
At first, one .fxml file kept being deleted repeatedly every time I would run the code.
Now, my ENTIRE PROJECT got deleted and I am totally lost.
The file that kept being deleted over and over again was inside of a package which contained other classes and another .fxml file which weren't ever deleted.
I am developing a JavaFX application.
UPDATE: All of the .fxml files of the project (.fxml files in all packages) got deleted physically from my SSD. So did my "lib"(which did contained active libraries) and my database file.
Only the class files have remained on the disk within the folder structer as they were. They are reachable through Windows explorer, but inside of InteliJ I literally saw how one by one everything was disappearing from the project structure until there was nothing left (just the "External Libraries" and the "Scratches and Consoles" are visible in the project structure).
UPDATE - 2 days later: I've not discerned the cause of all the above, but thankfully, I did push to GIT less than 5minutes to it all getting deleted. I did that because with how that single .fxml file was getting deleted I was worried of exactly what's happeneded happening, which is that my entire project gets deleted. I have sweeped through the logs and haven't found anything that seemed to be a clue as to what took place. I've restarted IntelliJ and imported the project anew, and that's what I'll end this with. I see not purpose in contacting IntelliJ support because I have no idea how to reproduce the issue.
I have an odd situation on a VS upgrade from 2013 > 2015 outside of runtime.
App Type: MS Lightswitch HTML Client
DB Type: Oracle
Framework: 4.5
Story: I upgraded VS and replaced OPD.Net to the 2015 version. Works fine.
Then I converted my application. There were a lot of things to fix, but most were pretty easily remedied. I tested the application and it works as expected so I published to test server and everything checks out. Success! So I thought.
I want to continue developing the site. As I make db changes, they need to be reconciled to the intrinsic db in my project.
After clicking 'Update Database' I see this. So far so good.
What's expected is that after I hit 'Finish', all changes to the selected table should pull in to the lsml files. But this is what I get.
I've read a few places like The given key was not present in the dictionary, what key? [closed] but these all look like runtime remediations.
If I go back to the update screen and hit 'Previous', I get this.
I sifted through every freakin lsml file in text editor looking for where the provider is assigned. No luck. I also created a new proj to compare, nothing stood out. I also tried adding another data source which works fine. So ODP.net is not the issue. I am lost on what to do now. I searched all over the site, Google, for every error message with various tags. At this point I reach out to you, or anyone that may know what this is about.
Thanks ahead of time!
Note for future users upgrading a VS LS project with Oracle db.
Since a new version ODP.Net is required (in my case 2015), the provider name is going to change. To ensure LS knows the new provider, the data source lsml file needs to be updated. In my case I used GIT to help out. This is how I resolved it.
Steps:
After converting your project and replacing ODP.net to the current version.
Create a new data source using the new provider.
Save the project and re-open. This will cause lightswitch to recompile.
Open File Explorer and navigatye to the ProjectName.server folder. In a text editor (I used notepad) open the lsml files under ProjectName.server and there should be two lsml files (1 for the pre-existing and another for the new) or more if you have multiple sources.
Copy the connection properties of the new datasource to a new temp file on your desktop.
Roll back the entire solution using GIT or other source control.
Use text editor to open the lsml file for the original data source.
Update the GUID for DataProviderName with the values from the temp file in step 4.
Note: The connection string GUID should be left alone as it should match your GUID in the web.config file.
<DataService.ConnectionProperties>
<ConnectionProperty
Name="DataProviderName"
Value="9d8fdbb9-xxxx-4787-xxxx-49831d34ad4b" />
<ConnectionProperty
Name="ProviderInvariantName"
Value="Oracle.ManagedDataAccess.Client" />
<ConnectionProperty
Name="ConnectionStringGuid"
Value="36e67aca-xxxx-41a7-xxxx-a4546761b30d" />
<ConnectionProperty
Name="ProviderManifestToken"
Value="12.1" />
</DataService.ConnectionProperties>
Finally reload project and the changes should take effect allowing you to once again update your data source.
Thanks
i'm using vs 2012- ef 5 working with model first approach, and the ef keeps on creating tow separate class files for each entity, one is as sub item under the model.tt file, and the other is within the model.designer.vb file.
i'v tried everything, and searched the web, but found nothing, even after entering the error code and desc. in msdn.
i'v also tried to remove the .tt file, but that lead to an exception and i got a message that "visual studio cannot locate the file ...tt"
i will really appreciate help, because i can't go on with my app.
I'm trying to use the VssGet task of the MSBuild Community Tasks, and the error message "File or project not found" is beating me with a stick. I can't figure out what in particular the error message is referring to. Here's the task:
<LocalFilePath Include="C:\Documents and Settings\michaelc\My Documents\Visual Studio 2005\Projects\Astronom\Astronom.sln" />
<VssGet DatabasePath="\\ofmapoly003\Individual\michaelc\VSS\Astronom_VSS\srcsafe.ini"
Path="$/Astronom_VSS"
LocalPath="#(LocalFilePath)"
UserName="build" Password="build"
Recursive="True" />
If I write a Streamreader to read to either the database path or the local path, it succeeds fine. So the path to everything appears to be accessible. Any ideas?
Two thoughts. One, sometimes a type load exception manifests as a FNF - let's hope that's not it. But if the code is actually being honest, you can track the problem using Procmon or Filemon. Start one of those utilities and then run your task again. You should be able to track down a record of a file that couldn't be located.
#famoushamsandwich that's a great response -- I had not previously heard of procmon or filemon. Tried procmon on the problem, but even after sifting through the relevant output (my gosh the machine does a lot more stuff behind the screen than I was aware of) I couldn't find where a file I'm referencing wasn't being found.
Procmon and Filemon are good suggestions - just make sure you filter the results to only show errors. Otherwise the success messages will bury the problem entries. Also, you can filter out processes that are not at fault (either through the filter dialog or by right-clicking the entry and choosing "Exclude Process".)
A couple other thoughts:
In the LocalFilePath, you are specifying a single file as opposed to a folder. The task, on the other hand, specifies to get files recursively. Perhaps you need to remove "\Astronom.sln" from the LocalFilePath?
Is the build task being run under your account or another? It's possible you have a permissions issue
Do you already have a copy of the code pulled down in the same location? Perhaps there is a failure to overwrite an existing file/folder?