Database schema dll I kept it inside.But I've added a primary key in two tables in the database.So I want to update dll.And the updated dll i want to get the current version of my project.How to update dll and add new version to project.
How to update model dll and insert use project.
Related
I am pretty new to the NestJS/typeorm system. So while working, I created an Episode entity and added some fields. Then I updated the entity to remove and update some fields. But after running the application, it still has the deleted columns ( checked it on pgAdmin ). The migrations are not updated to delete the columns. Is there any way to do it?
TypeORM kept the column definitions in a cache somehow and did not allow them to be deleted. This can be fixed by running rm -rf dist (or the Windows equivalent) and then rebuilding the project
At first I created Driver Definition in properties
Then I created new Data Design Project and Database definition file
After creating connection to db I selected database elements for the model.
Although I selected routines, It is not shown routines under packages in Database Explorer. All packages are shown empty.
In DB there are functions under marked packages. How to access them. the user which I connected by, have access to these functions.
I am using the ef core 2.0 CLI command scaffold-dbcontext to reverse engineer poco classes from an existing DB (database first). I want to put the generated classes from scaffold-dbcontext in a "Model" folder within my project but I want the namespace of the classes to be something different than "MyProjectName.Model". For example, I want the scaffold-dbcontext generated files to live in the Model folder but I want the namespace of the genereated files to be "MyProjectName.Entities".
Is there a way to control the generated namespace with the scaffold-dbcontext cli command?
(To give you a little background, I want to define the custom namespace in the generated pocos so I can have a separate set of partial classes in another folder which won't be overwritten by regenerating the model using scaffold-dbcontext).
Currently no way to specify namespace, but similar issue open for ef 2.1 milestone.
So I hope it will be fixed in the next version.
I have pulled down a Visual Studio 2015 project created my another developer. Within the Migrations folder are several Migration Configuration files ...
201601081315335_AddedPersonEntities.cs
201601091532275_AddedDepartmentEntities.cs
201601101145137_AddedPayrollEntities.cs
I would like to update my database to the point of one of these Migration Configurations. However when I try this command ...
Update-Database -Verbose -StartupProjectName MyApp.Api -ProjectName MyApp.Data -ConfigurationTypeName 201601091532275_AddedDepartmentEntities.cs
I get the following error ...
The migrations configuration type '201601091532275_AddedDepartmentEntities' was not be found in the assembly 'MyApp.Data'.
I was expecting it would bring my database up to the same schema at the point that 201601091532275_AddedDepartmentEntities was created. Am I missing something?
Go to visual studio, select your MyApp.Data and check the "Show All Files".
Inside the migrations folder, see if there aren't migrations "outside" the project. If there is, then add them to the project with Right-Click > Include in project.
Do you use TFS?
It happens when you add something (File/Folder) inside a project in your solution and check-in your solution, and your colleague doesn't do correctly the merge on the .csproj file (Which contains all the information about the files and folders inside the project).
WAIT
Ok i think this isn't the problem.
You are specifying -ConfigurationTypeName: don't you want -target: instead?
-ConfigurationTypeName Is used to define the configuration class (Normally contains the seed method).
-target Specifies to where you want to update your database (From the current migration to that specific one, forward or backwards it works anyway).
And, do you insert the models inside MyApp.Data or MyApp.Models?
Summary:
I'll start with the summary and then follow with the details. For my project, automatic migration is not happening on the live .sdf database file in the working directory. It's as if that .sdf file didn't exist. Instead, all configuration actions are performed on a new, empty database file which it creates on in the Program Files/Microsoft Visual Studio 10.0/Common7/IDE directory. How do I get it to work on my live .sdf database file in the working directory?
Details:
The project uses Code First EF in Visual Studio 2010 Ultimate. The project was started with EF 4.1, and I just updated the project to EF 4.4.
The database file is a SQL Server Compact Edition 4.0 file, which is located in the same directory as the executable (i.e., the working directory). Everything has been working fine for some time now, but I want to add two new DbSets to the DbContext, and hence two new tables to the database file. When I deploy the new version of the program to customers, I want the program to seamlessly just add the two new tables to the database, and continue on as if nothing had happened, leaving untouched all the extant data in the other tables.
Attempt 1
Per the process described in http://msdn.microsoft.com/en-US/data/jj554735:
I added to two new DbSets to the DbContext-derived class. When I attempted to run the program, I got the following exception: The model backing the 'DrillContext' context has changed since the database was created. Consider using Code First Migrations to update the database. This is what I expected to happen, since I hadn't yet enabled migrations.
In the Package Management Console I then issued the command:
Enable-Migrations -EnableAutomaticMigrations.
The system created a Migrations directory with a Configuration.cs file in it.
I then ran the
Update-Database
command, and got the message No pending code-based migrations. I checked the live database file in the working directory, and it was unchanged. There was, however, a new database file with the same name in the Program Files/Microsoft Visual Studio 10.0/Common7/IDE directory that had the same name and was an empty database with all the appropriate tables, including the two tables corresponding to the two new DbSets in the DbContext-derived class, and a new table named _MigrationHistory, which has a single entry in it. The live .sdf file remained untouched, without the new tables, and with no _MigrationHistory table.
Attempt 2, which uses an "InitialMigration":
Per http://www.ladislavmrnka.com/2012/03/ef-4-3-migrations-and-existing-database/
To prepare for the second attempt I restored the program's original state (i.e., to the state it was before I attempted the migrations) by doing 3 things. I removed the 2 new DbSets from the DbContext-derived class. I deleted the Migrations directory (and the enclosed Configuration.cs file), and deleted the useless database file (.sdf file) in the ".../Common7/IDE" directory.
I then executed the command:
Enable-Migrations -EnableAutomaticMigrations
which created the Migrations directory and the Configurations.cs file.
I then executed the
Add-Migration InitialMigration -IgnoreChanges
command, which added an 201208281905525_InitialMigration.cs file to the Migrations directory.
Then, per the directions on the cited web page, I modified the Up method in the file so that the InitialMigration class became the following:
public partial class InitialMigration : DbMigration
{
public override void Up()
{
Sql("DROP TABLE EdmMetadata");
}
public override void Down()
{
}
}
I then executed the
Update-Database
command, and got the message The specified table does not exist. I checked the live database in the working directory, and found that there is indeed an EdmMetadata table in the database. I then checked the .../Common7/IDE directory and found that the new database that had been created there did NOT have the table.
So all "migration" activity is occurring on the .../Common7/IDE version of the file but not on the live database file in the working directory.
How do I get it to work on the existing, live database file?
Thanks,