Entity Framework : Unable to change DataSource for Code First Migrations - sql-server

I am working on a project where I am using Entity Framework along with code first migrations to update my database. I started this project on another machine and it worked out very well. Now I checked out the code on another machine. Since this machine does not have the database, I ran update-database command in nuget. It should apply my previous migrations and create a new database on this machine but it is displaying following error.
error
I read this MSDN article which says
If a local SQL Express instance is available (installed by default with Visual Studio 2010) then Code First has created the database on that instance
If SQL Express isn’t available then Code First will try and use LocalDb (installed by default with Visual Studio 2012)
What I understand by this is when i enabled migrations in my first machine, it created database with SQLEXPRESS instance as DataSource and since I don't have that in my current machine, It is unable to create the database. So I am trying to change the DataSource of EntityFramework to the Instance of my current sql server which is LAPTOP-HD618J49. For this I tried to write a hard coded connection string with this instance in app.config, changed ContextName in Data Context class but to no avail. Please give me some directions on what I might be missing?

I finally resolved the issue. Earlier I tried to use base("name=ConnectionStringNameHere") but it didn't worked when I ran update-database command in package manager console. The strange reason is Visual Studio don't know which app.config to check for ConnectionStringName. Although I had already selected the module with entity framework in the dropdown of package manager console. I had to select the module with entity framework from the solution explorer window and set it as startup project. This somehow solved the problem and It was able to pick ConnectionStringName from app.config of the module with the updated DataSource.

Related

How to create a targeted dacpac without complications for ASP.NET Core web app and SQL Server database?

My yaml github workflow deployment build fails for actions/setup-dotnet#v1 looking for an unloaded SQL Server project. I don't understand why the build machine expects a SQL Server project file. I "Unloaded" the SQL Server project from my Visual Studio solution after creating the dacpac and before pushing. The same solution (now only .NET Core project with the unloaded SQL Server project) builds on my machine. The only reason I created the SQL Server project was for the dacpac.
C:\Users\runneradmin\AppData\Local\Microsoft\dotnet\sdk\5.0.400\NuGet.targets(290,5): error MSB3202: The project file "D:\a\rollbase\Database-Proj\Database-Proj.sqlproj" was not found. [D:\a\rollbase\rollbase\rollbase.sln]
Build FAILED.
Deleting the sql project to produce single proj solution builds successfully on github. So somewhere a reference to the unloaded project exists if it remains visible in VS Solution Explorer. Meaning the only way I can get the runner to build my solution is to delete the sql project after producing the dacpac each time. This seems clumsy and still leaves me not understanding the error.
This fairly recent post Developer Community Issue 2020 seems to indicate the same kind of problem but opposite fail situation. Though it doesn't help to only be able to read one half of the conversation.
Has anyone got a solution for my github DOTNET_VERSION: '5.0.400 build or a better process for getting a targeted dacpac during database updates for a net core solution? I would appreciate any input.

Vb.Net Application installer not updating access database

As the title says my vb.net application installer is not updating the correct database, the application works fine when debugging with visual studio, however when i install it the database in the data directory is not updated to the latest.
I use "Microsoft Visual Studio Installer Projects" to make an installer with all the needed files, this is how i have set it up:
Application Folder:
Image
User Desktop: I have just a shortcut to the .exe in the application folder
User's Program Menu: I have a folder with the app name and inside that a shortcut to the .exe in the application folder
When installed into the computer the database is not the latest and i know this because when i try to use a button with an insert query the app gives back an error non being able to find a column, "ID_User", that i just recently added.
Database connection string:
Dim conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\Account.mdb")
More Info:
I used the visual studio deployment wizard to create the setup files instead of the Visual Studio project installer and the application works just fine so i assume its a problem just with the other installer and how its configured but i cant figure out whats the problem, i always used it and never had problems until the latest release.
Edit:
I tried adding the database inside the application folder in the Visual Studio project installer and setting the property of the database to always copy it inside the output directory, still no luck.
Solution:
I don't know either what happened but somehow i might have messed up something in the database while editing it, i made a new one with the same fields and replaced the old one, now everything works just fine.
Edit 08 Jan 2021:
Same problem happened again, and this time i think i know why... i edited the database again but i didnt open the file directly but from Visual Studio solution explorer and then edited it. When i tried installing the new version it didnt work again and when i changed the database it started working again. So i think the problem is that the visual studio db editor doesn't save changes somehow.

The server content appears to be out of date. Would you like to build and deploy the project first?

i created cube in analysis services in VS 2017
my problem is i cant process .cube file to sql server
this is error message i get
The server content appears to be out of date. Would you like to build
and deploy the project first?
i have analysis services server opened in background
in services both analysis services server and sql server browser are activei would appreciate any kind of help
This means that the definition of the cube and/or database on your database server are different from what is in your project in Visual Studio. Meaning somebody made changes to one, but not the other.
You need to bring them into sync before you can process the cube from your Visual Studio project.
If you want to overwrite what's on the server with what's in the project, just build and deploy the project.
If you want to overwrite your project with what's on the server, you'll need to generate a new project by importing from your database, and use it to replace your existing one.
Thanks everyone i solved it
in deployment settings i set server destination as servername/user instead of servername

How to deploy SQLServer CE for VSPackage?

I like to deploy SQLServer CE privately on my VSPackage application.
I already tried the following information:
Using Entity Framework with an SQL Compact Private Installation
as well as this one:
How to deploy SQL Server Compact Edition 4.0?
But I still get the following exception message:
The specified store provider cannot be found in the configuration, or is not valid
I guess the above methods do not work for me because my VSPackage will appear as a DLL, while the above methods work for an .EXE application.
Any suggestion how can I do it?
Thanks
Most likely, Visual Studio cannot find and load one of SQL Server Compact Edition assemblies. By default, Visual Studio don’t look dependent assembles in a VSPackage folder if VSPackage code have not explicit reference to such assembles. I described several ways to solve this problem here. Hope it help you.

visual studio 2012 SQL CLR

I am trying to create, test and deploy a SQL CLR (database project) using Visual Studio 2012 (update 2) and it is getting very frustrating.
The coding itself was trivial but now I cannot deploy or execute unit tests on the project. I have developed SQL CLR in VS 2010 and it was much simpler (Test.sql).
So here are my questions:
How does one set up a local SQL script to test the newly minted functions/sprocs? [I have tried adding a .sql file and marking it to be run on debug but I get error SQL71006.]
How does one deploy the project? I am deploying to SQL 2008 R2 and I know I need to use .NET 2.0 but I still have not been able to deploy anything. When I execute the generated .SQL on the target SQL Server instance, nothing happens (no errors, nothing).
This has worked so well with previous versions of Visual Studio one wonders if MSFT is perhaps now trying to discourage the generation of SQL CLR modules?
For first point, ensure that .sql file in properties has anything then Build in field Action
For second point, try to use a Publish option, where you will get a dialog box to set up database connection and other config option.
Deploy option does nothing when you work with database projects.

Resources