ef-migrations

Unable to update database to match the current model because there are pending changes and automatic migration is disabled

大城市里の小女人 提交于 2019-12-01 03:51:29
问题 I, for the life of me, can't get rid of this error message. I have tried almost everything that I can. MyDBContext.cs public MyDBContext() : base("ConnStr_Dev") { } protected override void OnModelCreating(DbModelBuilder modelBuilder) { Database.SetInitializer(new MigrateDatabaseToLatestVersion<MyDBContext, DbMigrationsConfiguration<MyDBContext>>()); //Database.SetInitializer<MyDBContext>(null); base.OnModelCreating(modelBuilder); } GenericRepository.cs public void Insert(T obj) { table.Add

Making AddOrUpdate change only some properties

廉价感情. 提交于 2019-12-01 03:32:24
This might be a simple question, however I'm new to Code First and Migrations so bear with me. I'll keep sample code to a minimum to show the problem: I have a BaseAuditableEntity which includes this (among other things, but let's simplify): public abstract class BaseAuditableEntity : BaseEntity, IAuditableEntity { public DateTime CreatedOn { get; set; } public DateTime LastModified { get; set; } } Now a (for example) User POCO inherits from it: public class User : BaseAuditableEntity { public string UserName { get; set; } public string PasswordHash { get; set; } public string FullName { get;

Exception raised when I'm trying enable migrations in EF 4.3.1

痴心易碎 提交于 2019-12-01 03:32:10
I'm using Entity framework 4.3.1 installed by nuget in my .Net 4.0 class library project. In situation, when I call the "Enable-Migrations" command in PM console, I receive following exception: Exception calling "LoadFrom" with "1" argument(s): "Nelze načíst soubor nebo sestavení file:///D:\ Users\DvoracekR\Documents\Visual Studio 2010\Projects\WebCameras\packages\EntityFramework.4.3.1\to ols\EntityFramework.PowerShell.Utility.dll nebo jeden z jejich závislých prvků. Systém nemůže nalé zt uvedený soubor." At D:\Users\DvoracekR\Documents\Visual Studio 2010\Projects\WebCameras\packages

Entity Framework - How to get relative file path in seed method

谁说胖子不能爱 提交于 2019-12-01 03:30:28
Why is filePath null? Any ideas on how to get the relative filePath? internal sealed class Configuration : DbMigrationsConfiguration<MvcProject.Models.FileDb> { public Configuration() { // code here is not relevant to question } protected override void Seed(MvcProject.Models.FileDb context) { string filePath = System.Web.HttpContext.Current.Server.MapPath("~/Content/File.txt"); // read File.txt using filePath and update the database } } I have the above code in Configuration.cs file in Migrations folder created when entity framework is set up on an ASP .NET MVC project When I run "Update

Using NuGet Package Manager console outside Visual Studio to run Entity Framework Migrations

假如想象 提交于 2019-12-01 02:16:18
Is there anyway to open NuGet Package Manager console outside Visual Studio ? My objective is to run some migrations, which I created using EntityFramework.Migrations Basically I want to run Update-Database –Verbose command in an environment which does not have visual studio, but does have PowerShell 2.0 and NuGet command line tool. The original posted answer was right at the time, but now (as of 4.3) there is a migrate.exe so you don't need nuget or powershell: packages\EntityFramework.4.3.1\tools\migrate.exe See http://blogs.msdn.com/b/adonet/archive/2012/02/09/ef-4-3-released.aspx The link

Error : The EntityFramework package is not installed on project

南笙酒味 提交于 2019-12-01 01:31:27
问题 I've just installed SQL Server 2008, configured my ASP.NET MVC 4 project to be deployed at Local IIS and have added a new connection to a database which have been created at time (in sql server 2008). When I try to enable migrations (Entity Framework) via Enable-Migrations -ContextTypeName MonitoringNDataContext from Package Manager Console . I got this following error : The EntityFramework package is not installed on project 'MonitoringN.Tests'. Any brilliant idea, please ? MonitoringN :

Is there a way to make EF 5 code first migrations use a sql server database in ASP.NET MVC 4 for everything?

≯℡__Kan透↙ 提交于 2019-12-01 00:24:28
I would like for it to use SQL Server by default for everything when I start a new ASP.NET MVC 4 Web Application project. By default when you run this project it creates a LocalDb instance and creates the following tables in it: webpages_Membership webpages_OAuthMembership webpages_Roles webpages_UsersInRoles UserProfile I have been able to use a code first migration to put the UserProfile table into a SQL server database. However, I have not been able to accomplish this with the other 4 tables. Obviously my goal is to start with a single SQL Server database and have all of the tables for the

Exception raised when I'm trying enable migrations in EF 4.3.1

别等时光非礼了梦想. 提交于 2019-11-30 23:15:07
问题 I'm using Entity framework 4.3.1 installed by nuget in my .Net 4.0 class library project. In situation, when I call the "Enable-Migrations" command in PM console, I receive following exception: Exception calling "LoadFrom" with "1" argument(s): "Nelze načíst soubor nebo sestavení file:///D:\ Users\DvoracekR\Documents\Visual Studio 2010\Projects\WebCameras\packages\EntityFramework.4.3.1\to ols\EntityFramework.PowerShell.Utility.dll nebo jeden z jejich závislých prvků. Systém nemůže nalé zt

Using NuGet Package Manager console outside Visual Studio to run Entity Framework Migrations

怎甘沉沦 提交于 2019-11-30 21:45:24
问题 Is there anyway to open NuGet Package Manager console outside Visual Studio ? My objective is to run some migrations, which I created using EntityFramework.Migrations Basically I want to run Update-Database –Verbose command in an environment which does not have visual studio, but does have PowerShell 2.0 and NuGet command line tool. 回答1: The original posted answer was right at the time, but now (as of 4.3) there is a migrate.exe so you don't need nuget or powershell: packages\EntityFramework

Add an implementation of 'IDesignTimeDbContextFactory<ServicesDbContext>' to the project error while creating a migration step in .NET core 2.0

妖精的绣舞 提交于 2019-11-30 21:25:30
I had a .NET core 1.0 webapp working fine. I had to upgrade to .NET Core 2.0. I also had to add a migration step for my SQLite database. If I launch this command: Add-Migration MyMigrationStepName I get this error: Unable to create an object of type 'ServicesDbContext'. Add an implementation of 'IDesignTimeDbContextFactory' to the project, or see https://go.microsoft.com/fwlink/?linkid=851728 for additional patterns supported at design time. I've seen plenty of answers on SO and on other blogs and website but none of them actually say where to implement such interface and what code the