entity-framework-core-migrations

How to handle huge efcore migrations designer files that is slowing down build and IDE

落爺英雄遲暮 提交于 2021-01-20 15:37:39
问题 I currently have an efcore 2.1 project with about 230 entities and about 350 migrations. Every time i add an efcore migration, a designer file is created. This file is approximately 535 kb and growing (150mb total for alle designer files). This makes the IDE slow and unresponsive, refactoring is a no go, it also makes the build process slower. If i delete all designer files, the build goes down from 110 to 20 seconds, and the IDE gets snappy again. however, once I delete all designer files, i

How to handle huge efcore migrations designer files that is slowing down build and IDE

这一生的挚爱 提交于 2021-01-20 15:35:43
问题 I currently have an efcore 2.1 project with about 230 entities and about 350 migrations. Every time i add an efcore migration, a designer file is created. This file is approximately 535 kb and growing (150mb total for alle designer files). This makes the IDE slow and unresponsive, refactoring is a no go, it also makes the build process slower. If i delete all designer files, the build goes down from 110 to 20 seconds, and the IDE gets snappy again. however, once I delete all designer files, i

How to uninstall EF Core tables? Or how to remove all migrations ? Or how to call `dotnet ef database update 0` from user code?

别说谁变了你拦得住时间么 提交于 2019-12-29 01:51:30
问题 I'm developing web app and near it small command line application that install ef core tables in the DB. Last can be done calling dbContext.Database.Migrate(); and this works. Now I want to provide unistall option (with this app). But how to remove migrations (means call functionality of dotnet ef database update 0 from my code) ? It could be not one command call (as it was in case with dbContext.Database.Migrate(); ). But snippet with loop through all migrations in migrations assembly and

EF Core Migration error: Database 'MyDatabaseName' already exists. Choose a different database name

独自空忆成欢 提交于 2019-12-23 19:43:05
问题 I am running ASP.NET Core 2.1 with EF Core 2.1 application on Windows Server 2016 with SQL Server 2017 Web edition. At the end of public void Configure(IApplicationBuilder app, ... method in Startup.cs I call context.Database.Migrate(); . This applies migrations. Everything works. Now I backup database in my development environment in SQL Server 2016, move MyDatabaseName .bak file to server and restore database MyDatabaseName on server and restart IIS site. When I start application (open

How to add the support for structured annotations to the EF Core SqlServer target builder?

旧城冷巷雨未停 提交于 2019-12-11 13:18:12
问题 It is easy to add plain string annotations to the EF model with HasAnnotation method that accept object type of argument, but trying to add structured annotations you will get errors on build migration: modelBuilder.Entity<Group>().HasAnnotation($"{GetType().FullName}.Constraint3", new ValueTuple<string,string>( "aaa", "bbb" )); The current CSharpHelper cannot scaffold literals of type 'System.ValueTuple`2[System.String,System.String]'. Configure your services to use one that can.

Add-Migration Value cannot be null. Parameter name: language

社会主义新天地 提交于 2019-12-08 20:21:23
问题 I am trying to create a new migration but I get an System.ArgumentNullException saying: System.ArgumentNullException: Value cannot be null. Parameter name: language at Microsoft.EntityFrameworkCore.Utilities.Check.NotNull[T](T value, String parameterName) at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations..ctor (IOperationReporter reporter, Assembly assembly, Assembly startupAssembly, String projectDir, String rootNamespace, String language) at Microsoft.EntityFrameworkCore

ef core migration can't use secret manager

丶灬走出姿态 提交于 2019-12-04 04:10:26
问题 When I create .net core web applications, I use the secret manager during testing. I am generally able to create a new web project (mvc and web api), right click on the project and select "manage user secrets". This opens a json file where I add the secrets. I then use this in my startup.cs something like this: services.AddDbContext<ApplicationDbContext>(options => options.UseMySql(Configuration["connectionString"])); The website works fine with this and connects well to the database. However

How to uninstall EF Core tables? Or how to remove all migrations ? Or how to call `dotnet ef database update 0` from user code?

南笙酒味 提交于 2019-11-28 14:30:26
I'm developing web app and near it small command line application that install ef core tables in the DB. Last can be done calling dbContext.Database.Migrate(); and this works. Now I want to provide unistall option (with this app). But how to remove migrations (means call functionality of dotnet ef database update 0 from my code) ? It could be not one command call (as it was in case with dbContext.Database.Migrate(); ). But snippet with loop through all migrations in migrations assembly and call of 'Downs'. EF Core provides publicly only the dbContext.Database.Migrate(); extension method used

EF Core 2.0 how to use SQL stored procedure

二次信任 提交于 2019-11-28 11:12:50
I am new to EF Core 2.0 with stored procedure. Can anyone help how to use stored procedure in my EF Core 2.0 code-first approach? With my previous project, I had an .edmx model file, and I was using the context as below: public IEnumerable<UserResult> GetUserResults(Entities context) { if (context == null) return new List<UserResult>(); return context.spGetUsers().Where(u => u.IsDeleted == false); } and the context is: public virtual ObjectResult<UserResult> spGetUsers() { return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<UserResult>("spGetUsers"); } Thanks You can use the

EF Core 2.0 how to use SQL stored procedure

北城以北 提交于 2019-11-27 06:01:17
问题 I am new to EF Core 2.0 with stored procedure. Can anyone help how to use stored procedure in my EF Core 2.0 code-first approach? With my previous project, I had an .edmx model file, and I was using the context as below: public IEnumerable<UserResult> GetUserResults(Entities context) { if (context == null) return new List<UserResult>(); return context.spGetUsers().Where(u => u.IsDeleted == false); } and the context is: public virtual ObjectResult<UserResult> spGetUsers() { return (