Asp.Net Core migration path error - visual-studio-2017

I am trying to create a DB from EF Core migration.
With this connection string.
"ConnectionStrings": {
"DefaultConnection": "Server=(localdb)\\MSSQLLocalDB;Database=BookList_RazorDemo;Trusted_Connection=True;MultipleActiveResultSets=True"
}
The add-migration command on the PMC works fine, but when I execute update-database it give me an error saying that it cannot open or create the physical file 'C:\Users\[User]BookList_RazorDemo.mdf', the users name and the mdf file name are not separated by .
Is there a parameter I can specify with the update-database command to set my output path for the mdf file, or where can I set the output directory otherwise?
Thank you in advance.

You can specify the path to your .mdf file by adding AttachDbFileName to the connection string (Documentation):
Server=(LocalDB)\\MSSQLLocalDB;Integrated Security=true;AttachDbFileName=D:\Data\MyDB1.mdf

This is Fixed in latest SQL Server 2017 CU!
https://github.com/dotnet/ef6/issues/384#issuecomment-398313650

Related

How to read product code from an msi package?

I want to get the product code from an msi file before installing it. I need it to remove the other version of a product if it's already installed on my computer. I mean I want to prevent an error 1638 ("Another version of this product already exists...") and to delete it manually in my code. I'm using c++.
So I want to get the product code from the msi file that is about to install and using this product code remove the existing version of the product and install a new one. But when I'm trying to open an msi file to get it's handle using
MsiOpenPackage(msiPackagePath, &d_handle);
I get an error 1638. So I can not open an msi file and can not get a product code from it. My question: is it possible to get a product code from msi file not opening it with MsiOpenPackage? Thank you in advance!
My colleague has just solved a problem. We used a function MsiOpenPackageEx and passed a flag MSIOPENPACKAGEFLAGS_IGNOREMACHINESTATE to ignore the computer state and return a handle anyway.

AWS CodeDeploy ymal file error

I am deploying an application using AWS code deploy to Windows environment. I use an apspec.yml yaml file. When I deploy the application I get following error
The deployment failed because an invalid version value () was entered in the application specification file. Make sure your AppSpec file specifies "0.0" as the version, and then try again.
It seems like there is a problem with encoding or line ending. All the materials in the internet are for linux but not for windows. I use visual studio editor to edit this file. How to fix this issue?
In my case the encoding was wrong. appspec.yml should be saved as UTF-8 and not UTF-8 BOM.
BTW: The encoding can be changed in VS 2017 using File > Save as.., then the down arrow at the Save-Button ... Save with encoding...
The issue is in the line ending. If you create a yml file make sure you use \n line ending (linux way of line ending) instead of \r\n (windows way of line ending). If your editor is visual studio when you safe the yml file save it as follows.
File->Advanced Saved Options
Make sure your appspec.yml starts with below line
version: 0.0
codedeploy requires this attribute as must. refer this
Change the Encoding format by simply opening it notepad++ from UTF-8-BOM to UTF-8

'sc' is not recognized as an internal or external command

I am trying to create a svnserver using cmd after i changed svnserve.conf by uncommenting the following lines in the file,
anon-access = read
auth-access = write
command execute in cmd is,
sc create svnserver binpath= "C:\Program Files\TortoiseSVN\bin\svnserve.exe --service -r c:\Goods\Repo" DisplayName= "Subversion" depend= tcpip start= auto
but i am getting error
'sc' is not recognized as an internal or external command
I am not sure what i am doing wrong. I have installed tortoise SVN Client and Visual SVN Server.
Can someone please let me know what i am missing here.
you will need to add the path to sc.exe ("c:\windows\system32\") in your Path environment variable. Do this by hitting windows key + Pause|Break then selecting advanced system settings - environment variables is at the bottom. Just add an extra entry after the last - separated by semi-colons. If this isn't possible, simply give the command the full path of sc.exe e.g.
"c:\windows\system32\sc.exe" create svnserver....

AWS Codedeploy fails in DownloadBundle event saying No such file or directory

I'm using AWS Codedeploy to deploy my code from GitHub to AWS EC2 instance(Windows 2008 server). Deployment fails in DownloadBundle event
Error stack in logs of AWS :
No such file or directory - C:\ProgramData/Amazon/CodeDeploy/4fbb84fd-caa5-4d1a-9894-16b25abcea76/d-QUPXMDBCF/deployment-archive-temp/My-Application-163e9d3343be82038fe2e5c58a9fcae86683d4ea/src/main/java/com/myapp/dewa/customexceptions/EventNotPublishedException.java
The problem here might be with the file path limit of windows.
UPDATE: AWS CodeDeploy Support team has confirmed that this is a limitation from their side. More than half of the file path is being used by CodeDeploy because of which limit is being exceeded
Have you replaced some strings from the file_path and/or file_name?
This error you get when the total length of the file_path is beyond 260 characters. This length includes one null character at the end for termination. Your total length is 239+1 = 240.
For reference, please see this article: https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx#maxpath
If you check the path in the destination, you should not see the file because it was not copied but it is in your revision zip file.
In my case, the total length was 266. It may not be possible to shorten the strings of the actual file path in the revision since lots of them are created by the developer tools. Amazon is investing at their end now to see how to overcome this.
You can test and confirm by doing the following:
Run the following command in the command prompt to create the deployment archive folder:
mkdir "c:\ProgramDat0/Amazon/CodeDeploy/4fbb84fd-caa5-4d1a-9894-16b25abcea76/d-QUPXMDBCF/deployment-archive-temp"
Simply try to extract your revision zip file directly under 'deployment-archive-temp' folder.
You should received the following error for file crossing the maximum path length of 260:
'Error 0x80010135: Path too long'
Ref: https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx#maxpath
I hope this helps.
While not a complete solution, I've experienced the same problem and we were able to remove the preceding 'ProgramData\Amazon\CodeDeploy' to save 29 characters if you can stand the mess in your root folder.
To do this we modified the conf.yml file located in c:\programdata\amazon\codedeploy\
I changed ... root_dir: 'Amazon\CodeDeploy' ... to ... root_dir: 'C:\'
If you are using Windows 2016, setting the value to 1 for the following registry entry will fix the issue with long paths.
HKLM:SYSTEM\CurrentControlSet\Control\FileSystem
Referencing iskandar's post this can be done through a powershell script if you wish to automate it in something like a startup script.
# #see https://github.com/aws/aws-codedeploy-agent/issues/46
# #see https://learn.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file#paths
Write-Verbose "----> Enabling Long Path Support"
$RegistryPath = "HKLM:SYSTEM\CurrentControlSet\Control\FileSystem"
$Name = "LongPathsEnabled"
New-ItemProperty -Path $RegistryPath -Name $Name -Value 1 -PropertyType DWORD -Force | Out-Null
# You'll want to reboot to make sure; this is Windows we're working with.
Restart-Computer
You can also use the GUI method outlined in this post.
Note - either method will definitely require a restart for the setting to take affect

Connect to MS SQL Server through ODBC

I have a Qt 4 application that is trying to connect to an MS SQL Server 2008 database using the Qt ODBC driver. The application runs fine when it is running in Windows; however, the target OS for the application is to have it run in GNU/Linux. When the application runs in GNU/Linux I get the following error:
QSqlError(0, "QODBC3: Unable to connect", " [unixODBC][Driver Manager]Data source name not found, and no default driver specified")
Is there something I need to configure on the SQL server or application side to get the connection to work?
I don't really know much about unixODBC, but have a look here:
unixodbc.org/doc/
For connecting to MSSQL, the following might be useful:
http://www.unixodbc.org/doc/FreeTDS.html
or .../FreeTDS2.html
Try to copy the odbc.ini file in ~/.odbc.ini . If not working again, try to copy the same file into /etc/odbc.ini. If this is not working, as these directories are different for different Unix systems, find all files: *odbc*\.ini and see if some of them are empty. If so, replace them with the correct .ini file.
I had the same problem and this solved it. But it's a really stupid solution, so I'm looking for a better one. Hope that helped (: