ef-migrations

How do I create the asp.net Identity tables manually with migrations?

不羁岁月 提交于 2019-11-30 07:19:11
I would like the asp.net Identity tables to exist in my database, and as well, have the corresponding respective code-first models generated before I actually run the mvc app and create a user, so that I may code some logic against these classes before hand. Is there a way that I can create these tables/classes with migrations manually? Dylan Corriveau If you want to add it manually in your database, you'll have to write it in a Structured Query Language ;) CREATE TABLE [dbo].[__MigrationHistory] ( [MigrationId] NVARCHAR (150) NOT NULL, [ContextKey] NVARCHAR (300) NOT NULL, [Model] VARBINARY

Azure EF Code First Migration Initializer

a 夏天 提交于 2019-11-30 07:16:08
问题 I am just messing with Azure, and I can't seem to get my Db to work. I am following what it says here: https://www.windowsazure.com/en-us/develop/net/tutorials/web-site-with-sql-database/ and I updated my web.config to have this: <entityFramework> <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" /> <contexts> <context type="DownloadThis.Models.DownloadThisDb, DownloadThisDb"> <databaseInitializer type="System.Data.Entity

Entity Framework : Sharing entities across different DbContexts

余生颓废 提交于 2019-11-30 07:01:53
I'm developing a plugin application with EF6, code first. I have one main context with an entity called User : public class MainDataContext : DbContext { public MainDataContext(): base("MainDataContextCS") {} public DbSet<User> Users { get; set; } } And then another context for PluginX, on another project which references the base one: public class PluginDataContext : DbContext { public PluginDataContext () : base("MainDataContextCS") { } protected override void OnModelCreating(DbModelBuilder modelBuilder) { modelBuilder.HasDefaultSchema("PluginX"); base.OnModelCreating(modelBuilder); } public

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

馋奶兔 提交于 2019-11-30 06:22:49
I am using Visual Studio 2015 and dotnet core and trying to develop an EF Core Code First project using Sqlite and this documentation / tutorial, which also uses Sqlite => NET Core - New Database When I try to add an initial migration from the command line ( I am CD-ed into the folder that my data model project is located in) by issuing the following command dotnet ef migrations add InitialMigration ...I get the following Error. No project was found. Change the current working directory or use the --project option. I even tried using the --project option like so. > dotnet --project "C:\Shiva

Code first migrations - how to display pending model changes?

∥☆過路亽.° 提交于 2019-11-30 05:55:05
I'm using code first migrations. Is there a way to display pending model changes in package manager console before I scaffold a new migration? There is no way that I know of to view pending changes in the model before scaffolding the migration, but I can't think of a reason not to scaffold the migration using Add-Migration so that the pending changes can be viewed in the migration file. There is no need to apply those changes to the database and the scaffolded migration can always be deleted. Once the migration is scaffolded, if you use Update-Database -Script entity framework generates a SQL

How are the compressed models stored in the EF 4.3 Code First Migrations __MigrationHistory table created?

不想你离开。 提交于 2019-11-30 05:48:50
问题 I'm working with Code First Migrations (Entity Framework 4.3) and I'd like to get a compressed binary version of the current model, so that I can manually compare it to the latest model stored in the __MigrationHistory table (or to one I have stored in a text file). There is the EdmMetadata.TryGetModelHash() method, but that's marked as deprecated and I want to avoid it if possible (for future-proofing reasons). How would I do this under EF 4.3? Edit: From a bit more investigation and the

Entity Framework 6 - Does not create tables when enabling Migrations

半城伤御伤魂 提交于 2019-11-30 04:58:14
问题 In my application I enable Code First Migrations with some migrations, Also I use SQL Server Compact for integration test. When I run my tests, Entity Framework create an empty database and tries to run migration on that empty database and thrown The specified table does not exist. Based on this report I think usage of Migration in Entity Framework 6 has changed. I test all Database Initializer with Context.Database.Create(); but in all case tabale's never created. 回答1: I don't know that this

What is the correct format for Running Entity Framework migrate.exe tool without a Web/App.config?

折月煮酒 提交于 2019-11-30 04:43:15
We recently switched to Entity Framework data migrations and I am working on some build automation scripts for our MVC app. I can successfully run the migrations from our build server using the migrate.exe tool in 4.3 if I have a Web.config to point it at. The command looks something like: ProjectName\packages\EntityFramework.4.3.1\tools\migrate.exe MyAssembly /startupdirectory:ProjectName\bin\Debug /startupconfigurationfile:ProjectName\Web.config /verbose However, for various reasons I would like to avoid using the Web.config and just pass in the correct connection string at the time of the

Code first create tables

自闭症网瘾萝莉.ら 提交于 2019-11-30 04:07:25
I was following this tutorial, and I tried to add a few new columns in the userprofile table. And i tried to create a new table. public class UsersContext : DbContext { public UsersContext() : base("DefaultConnection") { } public DbSet<UserProfile> UserProfiles { get; set; } public DbSet<TestTabel> TestTabel { get; set; } } [Table("UserProfile")] public class UserProfile { [Key] [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)] public int UserId { get; set; } public string UserName { get; set; } public string Mobile { get; set; } public string FirstName { get; set; } public string

EF Code First Migration with Multiple Database / DbContext

点点圈 提交于 2019-11-30 04:00:41
I have two database each with their own dbcontext. I've setup two migration configurations. I can add a migration for the first db ust fine ( Add-Migration DB1_InitialCreate -ConfigurationTypeName DB1Configuration ). When I try to create an initial migration with the second db using: Add-Migration DB2_InitialCreate -ConfigurationTypeName DB2Configuration , I get the following error: Unable to generate an explicit migration because the following explicit migrations are pending: [201205082215265_DB1_InitialCreate]. Apply the pending explicit migrations before attempting to generate a new