That meant that something in the Alpine Linux must be causing this. I tried running the bundle in a container running Ubuntu image, and it worked fine. The migration bundle was built with a linux-圆4 runtime ID, which fit the image the Docker container was running on. After adding some logging, it was clear the bundle was starting and then doing nothing. The problem was simple - the bundle was starting the application and then hanging. The last issue doesn't have a stack trace or an error message. If it's not, the migrations might fail because of wrong configuration or missing extensions. Side note #2: Make sure the AddDbContext call is the same as your regular one (bar the connection string). By adding these two simple methods and setting the environment accordingly, the build is faster and more resilient as it skips the unnecessary code. The exception isn't thrown there because the configuration is available. Side note: A similar thing occurs when the bundle is built - the application is started and goes through all the code in the Startup class. Now it's just a matter of setting the ASPNETCORE_ENVIRONMENT variable to BuildDeployment and voilà! The error is gone. A connection string is necessary because otherwise, the setup will fail, but the dummy string works very well. You can provide the connection string as a parameter to the bundle with the -connection switch. Note the dummy connection string in there - that's on purpose. Public void ConfigureBuildDeployment(IApplicationBuilder app, IWebHostEnvironment env) Options.UseSqlServer("Server=myServerAddress Database=myDataBase User Id=myUsername Password=myPassword ")) public void ConfigureBuildDeploymentServices(IServiceCollection services) It should only require the DbContext to be configured. In it, there is a section Environment-Specific method conventions which helps accomplish exactly that.īy adding the two following methods to the Startup class, the bundle is able to skip all the startup code it doesn't have any business in. There is a great article on Andrew Lock's blog called Configuring environment specific services in ASP.NET Core - Part 2. There must be a better way - the bundle shouldn't need to go through all the clutter in Configure and ConfigureServices just to run the migrations. It would most likely solve the problem but seems a bit hacky. Another option would be copying a dummy appsettings.json file alongside the bundle executable. On the other hand, you might want to prevent application startup if the configuration is missing. First, the code in the Startup class could be changed so that no nulls would be added to the service provider. Var someConfig = _configuration.GetSection("someConfig").Get() īecause appsettings.json was not present, the someConfig variable was null and that was the problem. Public void ConfigureServices(IServiceCollection services) Public Startup(IConfiguration configuration) Unable to create an object of type 'ApplicationDbContext'.įor the different patterns supported at design time, see Īfter digging into the exception, it turned out that this piece of code was causing it: public class Startup Issue #2 An error occurred while accessing the services.Ĭontinuing without the application service provider.Įrror: Value cannot be null. Running apk add gcompat before executing the bundle solved the problem. Thankfully, Googling this one resulted in finding a simple fix. This looks like there are some dependencies missing. tmp/migrations-artifact/efbundle: _isnanf: symbol not found tmp/migrations-artifact/efbundle: _isnan: symbol not foundĮrror relocating. tmp/migrations-artifact/efbundle: _strdup: symbol not foundĮrror relocating. tmp/migrations-artifact/efbundle)Įrror relocating. Issue #1 Error loading shared library ld-linux-x86-64.so.2: No such file or directory (needed by. Since they are supposed to be self-contained, I did not expect any problems to appear. Recently, I wanted to run the bundle inside a Docker container running an image based on the Alpine Linux distro. If this is the first time you're hearing about them, there's a short introduction in one of my earlier posts. Entity Framework Core Migration Bundles can greatly ease the process of applying database changes during the deployment of your application.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |