Is it possible to change the location of the EF Migrations “Migrations” folder?

In the configuration class constructor add this line: this.MigrationsDirectory = “DirOne\\DirTwo”; The namespace will continue to be set as the namespace of the configuration class itself. To change this add this line (also in the configuration constructor): this.MigrationsNamespace = “MyApp.DirOne.DirTwo”;

EF Data migrations won’t detect changes when adding new migration

I had a similar problem where a new migration was not being found, and so update-database was giving me the following error no matter what I did: Unable to update database to match the current model because there are pending changes and automatic migration is disabled. Either write the pending model changes to a code-based … Read more

Can you create sql views / stored procedure using Entity Framework 4.1 Code first approach

We support stored procedures in our Entity Framework Code First Migrations. Our approach is to create some folder to hold the .sql files (~/Sql/ for example). Create .sql files in the folder for both creating and dropping the stored procedure. E.g. Create_sp_DoSomething.sql and Drop_sp_DoSomething. Because the SQL runs in a batch and CREATE PROCEDURE.. must … Read more

Consolidating EF migrations into new InitialCreate

Consider reading this nice article from Rick Strahl : https://weblog.west-wind.com/posts/2016/jan/13/resetting-entity-framework-migrations-to-a-clean-slate Basically the solution is not trivial and needs more than just reseting all the migrations into one because you have two scenarios that needs to fit in ONE migration class: Create a new database => the migration class should contain every table creation My database … Read more

EF Core Error – No project was found. Change the current working directory or use the –project option

sometimes you need to change the current directory in console/terminal eg: PM> cd E:\Projects\CrossTest\ PM> dotnet ef migrations add InitialMigration and Align your package versions. Either use preview1 packages or preview2. Mix of those are not supported.

EF migration for changing data type of columns

You have a default constraint on your column. You need to first drop the constraint, then alter your column. public override void Up() { Sql(“ALTER TABLE dbo.Received DROP CONSTRAINT DF_Receiv_FromN__25869641”); AlterColumn(“dbo.Received”, “FromNo”, c => c.String()); AlterColumn(“dbo.Received”, “ToNo”, c => c.String()); AlterColumn(“dbo.Received”, “TicketNo”, c => c.String()); } You will probably have to drop the default constraints … Read more

C# Code-First migration, up/down?

The Up method upgrades your database from its current state (represented by your previous migration) to the state expected by your current code migration. The Down method does the reverse operation – it removes all the changes from the current migration and reverts database to the state expected by the previous migration. It’s like installing … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)