Entity Framework add-migration when using Vagrant - entity-framework-6

I'm using vagrant to host my DB and website, but I make changes to my project locally and push changes to the vagrant site. I can run migrate.exe to update the DB but I can't figure out how to run add-migration? If I run it locally, it says I have pending changes because I have no DB locally? Can anyone point me in the right direction?

One option to update database without use dotnet ef database update is execute the command bellow in some default action or startup routine
_dbContext.Database.Migrate();

Related

Database migration for .Netcore MVC project in Mac

I am just into dotnet and I am finding it difficult as most of the resource is available only for windows.
I have the docker running. When I try to update the database (dotnet ef database update) in the command terminal, it builds and shows an error saying "Connection string keyword 'server' is not supported."
The project is empty and its the default one after creating a new project with MVC
For incorporating Server in the visual studio I made few changes in the app settings.json
"ConnectionStrings": {
"DefaultConnection": "Server=localhost;Database=leavemanagementnet6;User=SA;Password=MyPassword123#;"
},
By default, it uses SQL Lite. Under program.cs, it should be changed to UseSqlServer(connectionString).
Also, the default migration has to be removed and created again. If its not done, we will be facing error while updating.
dotnet ef migrations remove
dotnet ef migrations add CreateIdentity -o Data/Migrations

How to configure database in Baeldung spring-security-registration application?

I am trying to train myself on Spring security and started looking at Baeldung.com website and examples posted for public download at github repository https://github.com/Baeldung/spring-security-registration. I downloaded the source code in this repository as ZIP and imported in netbeans. Following the instructions in README.md, I built it using mvn clean install. Application spring-security-login-and-registration downloaded all dependencies and built clean. But I don't have a clue how to configure the MySQL database needed for this application.
Do I need to download MySQL server and have a server instance on my localhost?
If yes, where would I get the scripts to create the schema/tables needed in the security application? I can't find the scripts anywhere in source code. Anything similar to hSQL going on here?
Any help is appreciated.
Yes you need to download MySql from here https://dev.mysql.com/downloads/windows/installer/8.0.html.
And need to configure few things during installation like username and password.
And update these fields inside you database properties file.
################### DataSource Configuration ##########################
jdbc.driverClassName=com.mysql.cj.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/YourDatabaseName?createDatabaseIfNotExist=true
jdbc.user=YourUserNameForMySql
jdbc.pass=PasswordHere
You can start you mysql on windows by executing this command:-
"C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe" on command prompt
Meanwhile you can login to mysql shell using this below command on terminal:-
mysql -uroot -proot

Entity Framework migrate.exe not working after updating to AspNet.Identity

Since updating my solution to use ASPNET Identity instead of the old membership, the migrate.exe commando to update database schema stopped working. The only major change is that my Context now inherits from a IdentityDbContext, when before it inherited from a DbContext.
Everything works fine running update-database on package manager console, but using migrate.exe on the command line doesn't work anymore. I get the error:
System.Data.Entity.Migrations.Infrastructure.MigrationsException: No migrations configuration type was found in the assembly 'SampleProject.Repository.EF'. (In Visual Studio you can use the Enable-Migrations command from Package Manager Console to add a migrations configuration).
I have a Configuration.cs file for the migrations, as always had and when running the "enable-migrations" suggested I get a message saying that migration are already enabled for the project.
Does anyone knows what the problem might be?
Thanks
Just a quick update on the solution.
It was DLL version conflict when running migrate.exe.
I was using the output from my web project (which also contained DLL for the EF project).
I updated it in order to use the bin content of my EF project and it worked just fine.

Run Migrations command if not have visual studio

I'm publishing a website ASP.NET MVC and get this error:
“Migrations is enabled for context ‘Context’ but the database does not exist or contains no mapped tables. Use Migrations to create the database and its tables, for example by running the ‘Update-Database’ command from the Package Manager Console.”
I can't install visual studio on server so i can't run ‘Update-Database’ command.
How to solve this problem ?
Find migrate.exe (YourApp\packages\EntityFramework.6.1.3\tools) and paste it in bin folder on the server.
Open Command Prompt on the server.
Run below commands
cd "C:\Websites\YourApp\bin" migrate.exe YourAppName.Api.dll /startupconfigurationfile:..\Web.config /verbose
Please Note that YourAppName.Api.dll should be the DLL having Enabled Migration.
you do not need to install visual studio on the server.
if you have your database connection string setup in web.config you should be able to run update-database in the package manager console and it will update your database on your web host.

Neo4j StartService FAILED 1053 after copying Beer DB example

I installed Neo4j as instructed in the site and was able to install and stat server. However I tried to copy the Beer example DB by stopping the server and deleting the current graph.db in the \data folder and replaced with the one Beer example downloaded from online (graph.db folder). This is the only step I did.
Now the issue is, when i tried to start the Server I get "StartService FAILED 1053"
I am using following command on the powershell in windows - c:\neo4j-community-2.0.0-M03> .\bat\Neo4j.bat start
Can someone please help if I have done anything wrong here.
Thank you!
You are running neo4j 2.0 against an older database file. You'll need to set the config parameter to allow the store to be upgraded before starting. See instructions here:
http://docs.neo4j.org/chunked/milestone/deployment-upgrading.html#_explicit_upgrade

Resources