ef-migrations

EF 4.3 Migration - how to produce a downgrade script?

吃可爱长大的小学妹 提交于 2019-12-21 07:37:49
问题 I have an issue which I could not find answer for across the web. I am using CodeFirst EF 4.3.1 Migrations with MsSQL. I have added several migrations and now I want to produce a script for upgrade/downgrade between two migrations. For upgrade I run the following command which successfully reproduces an upgrade script: PM> Update-Database -Script -SourceMigration:"201205161144187_AddPostAbstract" -TargetMigration:"201205161203310_BlogLimitsAndTableRename" However, for downgrade I run the

VS 2015 ASP.NET Web API (EF6) & Xamarin Enable-Migrations fails

守給你的承諾、 提交于 2019-12-21 06:58:23
问题 I'm developing a project that will use ASP.NET Web API as the data service, and a Xamarin portable app as client. I'm trying to enable migrations in the web app, but I get the following error: Enable-Migrations -enableautomaticmigrations -ContextTypeName MyProject.Models.ApplicationDbContext -ProjectName MyProject -StartupProjectName MyProject.App -Verbose Using StartUp project 'MyProject.App'. Exception calling "SetData" with "2" argument(s): "Type 'Microsoft.VisualStudio.ProjectSystem.VS

Where should EF Migrations go, my Class Library project or my ASP.NET project?

帅比萌擦擦* 提交于 2019-12-21 04:42:28
问题 My solution contains: FooBarAsp , an asp project (provides a UI for the application) FooBar , a class library (the application) FooBar.Tests , a test project (tests the application) FooBar uses EF 6 Code First, and contains a number of models, and a DataContext . FooBarAsp uses Microsoft's Identity framework for user authentication, and has an ApplicationDbContext . Both contexts play nice and work as expected. Global.asax.cs should execute MigrateDatabaseToLatestVersion (right?). FooBar

How do I create a migration for an existing database in EntityFramework 4.3?

随声附和 提交于 2019-12-21 04:28:17
问题 so I want to get started with EntityFramework 4.3 migrations. I wanted to know if I can convert an existing database to a migration-enabled database and have EF assume that only changes from then on should be considered migrations. 回答1: A nice walk-through for this is posted here: http://thedatafarm.com/data-access/using-ef-4-3-code-first-migrations-with-an-existing-database/ The one change I would suggest is to simply comment out the code in the Up and Down methods until you have deployed

Cannot create more than one clustered index on table

≡放荡痞女 提交于 2019-12-21 03:55:19
问题 I am having the following error after typing update-database: Cannot create more than one clustered index on table 'dbo.AppUsers'. Drop the existing clustered index 'PK_dbo.AppUsers' before creating another. I am working on an Azure mobile service. I have three data models: public class AppUser : EntityData { public string Username { get; set; } public virtual ICollection<RatingItem> userRatings { get; set; } } public class PlaceItem : EntityData { public string PlaceName { get; set; } public

Entity Framework Core migration - connection string

為{幸葍}努か 提交于 2019-12-21 03:20:53
问题 I'm having a problem to handle the DB connection string in conjunction with migrations. I have 2 projects: Domain Application The DbContext is in the Domain project, so this is the project I run migrations against. The migrations concept enforces me to implement OnConfiguring in my DbContext and therein specify the database provider, eg: protected override void OnConfiguring(DbContextOptionsBuilder builder) { builder.UseSqlServer("<connection string>"); } My problem is that I don't want to

Generating seed code from existing database in ASP.NET MVC

橙三吉。 提交于 2019-12-21 02:29:26
问题 I wondered if anyone has encountered a similar challenge: I have a database with some data that was ETL'ed (imported and transformed) in there from an Excel file. In my ASP.NET MVC web application I'm using Code First approach and dropping/creating every time database changes: #if DEBUG Database.SetInitializer(new DropCreateDatabaseIfModelChanges<MyDataContext>()); #endif However, since the data in the Database is lost, I have to ETL it again, which is annoying. Since, the DB will be dropped

EF Code First - Timeout expired. The timeout period elapsed prior to completion

心已入冬 提交于 2019-12-20 17:05:12
问题 Apology for this strangely worded question. I don't know what the actual problem is but hopefully someone can give me some insights. I am getting the following error when trying to run migrations: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. ---> System.ComponentModel.Win32Exception (0x80004005): The wait operation timed out It is interesting to note that on my laptop this is not happening but on my VM (azure - large) this

Entity Framework 5 Code First - How to “start over”?

青春壹個敷衍的年華 提交于 2019-12-20 10:48:29
问题 I've been using EF 5 Code First, successfully, in my app. I have roughly 40 tables. However, I've run into an issue that I can seem to get Migrations to handle correctly. So, what I would like to do is to somehow tell EF to treat the current schema of the database as a new starting point, and start managing it from this point. This way, I can make the necessary schema change manually, and then tell EF to essentially start over from this point. Is there a way I can do this? I presume I'm going

Schema independent Entity Framework Code First Migrations

强颜欢笑 提交于 2019-12-20 10:46:48
问题 I have troubles using Entity Framework migrations targeting Oracle databases since schema name is included in migrations code and for Oracle, schema name is also user name. My goal is to have schema-independent Code First Migrations (to be able to have one set of migrations for testing and production enviroments). I have already tried this approach (using Entity Framework 6.1.3): 1) I have schema name in Web.config: <add key="SchemaName" value="IPR_TEST" /> 2) My DbContext takes schema name