ef-migrations

Why I can't get Entity Framework Migration to initial state?

故事扮演 提交于 2019-12-05 04:43:02
问题 I have deleted development database, and Migrations folder from project. When running unit test with use my project development database is recreated. I don't understand why running update-database gives me PM> Update-Database Specify the '-Verbose' flag to view the SQL statements being applied to the target database. Applying code-based migrations: [201302201840012_wieleDoWielu]. Applying code-based migration: 201302201840012_wieleDoWielu. Why migration: 201302201840012_wieleDoWielu is

The specified deps.json '$$$' does not exist

こ雲淡風輕ζ 提交于 2019-12-05 04:32:56
I am rather new to the .NET Core, and I got a .NET Core WebAPI project MyWebApp, also, i have .Net Core Class Library project MyLib using EntityFrameworkCore When i try to use Add-Migration, i get the error The specified deps.json [...\MyWebApp\bin\Debug\netcoreapp1.1\MyWebApp.deps.json] does not exist Inspecting the folder, I noticed I have this a file in [...\MyWebApp\bin\Debug\netcoreapp1.1\win10-x64\MyWebApp.deps.json] but i really can't figure what i am supposed to do to resolve this. myWebApi project.json: { "dependencies": { "ShopManager": "1.0.0-*", "Microsoft.AspNetCore.StaticFiles":

Code-First Add-Migration keeps adding the same column

浪子不回头ぞ 提交于 2019-12-05 04:18:42
My model contains, among other things, two properties that were added to the model class after its initial creation and migration. public sealed class SomeModel { ... other properties, which are fine. public int PropertyOne { get; set; } public int PropertyTwo { get; set; } } My most recent migration contains: public override void Up() { ... other table being created. AddColumn("dbo.SomeModel", "PropertyOne", c => c.Int(nullable: false)); AddColumn("dbo.SomeModel", "PropertyTwo", c => c.Int(nullable: false)); } The target database contains the PropertyOne and PropertyTwo columns, and the _

System.Resources.MissingManifestResourceException when Updating database

时光毁灭记忆、已成空白 提交于 2019-12-05 03:51:37
I moved a web application I am working on from one machine to another. It is built using .Net MVC and Entity Framework but when I execute the Update-Database command so that the database is updated, I get this error: Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "NameofMigration.resources" was correctly embedded or linked into assembly "NameofProject" at compile time, or that all the satellite assemblies required are loadable and fully signed. Does anyone know how to fix this error? I had a similar issue when the resx part of the migration

Entity Framework 7 Reverse Engineering ASP.NET 5

你。 提交于 2019-12-05 02:37:10
问题 I have been trying to migrate my database into web app model using EF7 _4. Couple things I realized is that the syntax/approach how to configure particular entities has been changed. Normally you generate POCO classes by using EF Power Tools (EF6), which generates entity types and entity map as configuration. All clean, all works. My question is, does someone experience how to do it with EF7? From the msdn blog I have found here about Entity Framework 7 Beta 4 the features for reverse

EF 5.0 Enums Not Generating

泪湿孤枕 提交于 2019-12-05 01:00:48
问题 BACKGROUND I'm using VS 2010 on a machine where I installed .Net 4.5 which I've read was an in-place install (overrode the .net 4.0 version). I have projects still targeting 4.0 and 4.5 option is not available but was told it's ok since 4.5 was an in-place install. I then installed EntityFramework -pre via nuget and notices when I ran Upgrade-Database -Script commands, it would not generate enum properties. I then found this. I tried doing everything from scratch again but it was still adding

SetExecutionStrategy to SqlAzureExecutionStrategy with DbMigrationsConfiguration?

ⅰ亾dé卋堺 提交于 2019-12-04 23:07:23
I saw a post today about implementing SqlAzureExecutionStrategy: http://romiller.com/tag/sqlazureexecutionstrategy/ However, all examples I can find of this use a Configuration that inherits from DbConfiguration. My project is using EF6 Code First Migrations, and the Configuration it created inherits from DbMigrationsConfiguration. This class doesn't contain a definition for SetExecutionStrategy, and I can find no examples that actually combine SqlAzureExecutionStrategy (or any SetExecutionStrategy) with DbMigrationsConfiguration. Can this be done? If anyone else comes across this question,

Where can I find the console or debug output from code executed in the package manager window?

荒凉一梦 提交于 2019-12-04 22:12:20
I'm using EntityFramework code first with migrations. From the package manager console, I'm running "update-database". This executes Configuration.Seed(context) which I have overridden. protected override void Seed(WebContext context) { Console.WriteLine("Console Test"); Debug.WriteLine("Debug Test"); Trace.WriteLine("Trace Test"); } Where can I find that output? Better yet, How do I output back to the package manager window? Thx, Dan Where can I find that output? Sorry, but the quick answer is basically nowhere. To be precise at least not in the package manager console. Debug.WriteLine("Debug

Changing primary key data type in Production DB

白昼怎懂夜的黑 提交于 2019-12-04 20:32:08
I am using EF code-first. I need to change the datatype of primary key of one table in our production database. public class Course { [Key] public Guid Id {get; set;} //This needs to be changed to int public string Name {get;set;} public virtual ICollection<Group> Groups {get;set;} } public class Group { [Key] public Guid Id {get; set;} public string Name {get;set;} public virtual ICollection<Course> Courses{get;set;} } As the above is a Many-Many relationship, EF has created a join table GroupCourses automatically with PK & FK as both Group_Id and Course_Id . Which is fine until now. Now I

Keyword not supported error in Enabling migrations

心不动则不痛 提交于 2019-12-04 19:34:20
I have a dbcontext class where i have initialized 4 dbsets. My connection string is <connectionStrings> <add name="somename" connectionString="Data Source=.; initial catalog=someDb; user ID=ab; Password:111111; MultipleActiveResultSets=True;" providerName="System.Data.SqlClient" /> </connectionStrings> My dbcotext class is public AstroEntities(): base("somename") { Database.SetInitializer<AstroEntities>(new CreateDatabaseIfNotExists<AstroEntities>()); } protected override void OnModelCreating(DbModelBuilder modelBuilder) { modelBuilder.Entity<Contact>().ToTable("Contacts"); modelBuilder.Entity