![]() You need to write some additional code to create the DbContext to test the business layer in the Csla Extensions and custom DbContextManager. In addition if you are writing unit tests, to test the CSLA Business Objects specifically & you are not specifying a database "name". NET Core project can utilize the extensions. Then we created a separate assembly to house the Csla Extensions methods, so that the DbContextManager and the ASP. We decided the custom DbContextManager lives in the specific DAL Entity Framework layer (or assembly). ![]() The issue becomes where does the custom DbContextManager live and the custom Csla Extension methods live (in the linked article by rocky above) within the solution. NET Core UI layer & the specific DAL EF layer. (& because people would just call the DAL directly from the UI potentially).įirst the Entity Framework model needs to be in a separate library referenced to the ASP. There are some architectural decisions & exceptions first noted by goal was to not have the DAL (with all the Linq EF queries) referenced to the UI with the EF model because it Startup.cs you have to add the DbContext to the Services. Template: Yes, the key is to do what Rocky said to follow almost what was said in the linked issue above. LoggerFactory.AddLog4Net(new Log4NetProviderOptions("./Logs/log.txt", true)) Public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) ![]() Use this method to configure the HTTP request pipeline. This method gets called by the runtime. Options.MinimumSameSitePolicy = SameSiteMode.None Options.CheckConsentNeeded = context => true This lambda determines whether user consent for non-essential cookies is needed for a given request. Options.UseSqlServer("Server=localhost Database=Test user=root password=password") Options.UseMySql("Server=localhost Database=Test user=root password=password") If (string.Compare(Configuration, "mysql", true) = 0) Services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2) Public void ConfigureServices(IServiceCollection services) Use this method to add services to the container. ![]() Public Startup(IConfiguration configuration)Ĭonfiguration = new ConfigurationBuilder() If you are using dependency injection, you should let the dependency injection container take care of disposing context instances. This may occur if you are calling Dispose() on the context, or wrapping the context in a using statement. A common cause of this error is disposing a context that was resolved from dependency injection and then later trying to use the same context instance elsewhere in your application. To retrieve the object I am using the DI dataportal in the Razor Page constructor.Ĭsla.DataPortalException: 'DataPortal.Fetch failed (Cannot access a disposed object. I have looked at the source and found NO interaction specifically and by all means I dont see why it doesnt work. Or vice versa, if I remove Csla from Startup everything works. If I remove that line (& or the Microsoft identityįramework configuration because it calls the exact line) everything works. The culprit is services.AddHttpContextAccessor(). Although IMMEDIATELY after using (()) the DbContext is disposed. My question is how to configure APS.NET CORE Startup.cs? When configuring the Startup.cs as such the DbContextManager has a RefCount of 2 on the second database operation in a single request. I have created a fresh solution for you to look at if you need the exact code let me know where to upload it. This may be beneficial for anyone else looking into the latest and greatest. So I've been able to reproduce the exact circumstance I have found. First sorry that this is my second post about this topic but I am unable to figure out how to configure CSLA.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |