Entity Framework Seed method exception - entity-framework-6

I am using Entity Framework 6 with an MVC5 webapi2 project against an Oracle database.
I am trying to add some ApplicationRoles in the Seed method, but when I execute update-database I get this exception:
Running Seed method.
System.Runtime.Serialization.SerializationException: Type is not resolved for member 'Oracle.ManagedDataAccess.Client.OracleException,Oracle.ManagedDataAccess, Version=4.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342'.
at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
at System.Data.Entity.Migrations.Design.ToolingFacade.Run(BaseRunner runner)
at System.Data.Entity.Migrations.Design.ToolingFacade.Update(String targetMigration, Boolean force)
at System.Data.Entity.Migrations.UpdateDatabaseCommand.<>c__DisplayClass2.<.ctor>b__0()
at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command)
Type is not resolved for member 'Oracle.ManagedDataAccess.Client.OracleException,Oracle.ManagedDataAccess, Version=4.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342'.
My code in the Seed method:
var roleStore = new RoleStore<IdentityRole>(context);
var roleManager = new RoleManager<IdentityRole>(roleStore);
if (!context.Roles.Any(r => r.Name == "USER"))
{
var role = new IdentityRole("USER");
roleManager.Create(role);
}
update-database is creating my tables without any problem, it's just the Seed method which has a problem.
Does anyone have any suggestions as to what the problem could be please?
Thanks.

Installing Oracle.ManagedDataAccess.dll to GAC resolved my issue. If you installed Oracle Client or Oracle Database on your machine that might be the cause.
C:\Windows\system32>cd E:\smn\packages\Oracle.ManagedDataAccess.12.1.021\lib\net40
C:\Windows\system32>e:
E:\smn\packages\Oracle.ManagedDataAccess.12.1.021\lib\net40>"C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\gacutil.exe" /i Oracle.ManagedDataAccess.dll
Microsoft (R) .NET Global Assembly Cache Utility. Version 4.0.30319.33440
Copyright (c) Microsoft Corporation. All rights reserved.
Assembly successfully added to the cache

Related

F# Type provider FSharp,Data.SqlClient targeting .NetStandard 2.0 fails when using dotNet Build from commandLine but succeeds in Visual Studion 2019

I am using the F# Type Provider FSharp.Data.SqlClient in a DLL targeting .Net-Standard-2.0, while this successfully builds in Visual Studio 2019 it fails when I try to build it using the command prompt compiler dotNet compiler with the following error message
J:\Workspaces\DRILQUIP_2456764.0\Applications\EngWeb\Dev\src\EngWeb.Core\BillOfDocuments\BillOfDocumentsDataAccess.fs(14,27): error FS3033: The type provider 'FSharp.Data.SqlProgrammabilityProvider' reported an error: Could not load file or assembly 'System.Data.SqlClient, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context. (0x80131058) [J:\Workspaces\DRILQUIP_2456764.0\Applications\EngWeb\Dev\src\EngWeb.Core\EngWeb.Core.fsproj]
J:\Workspaces\DRILQUIP_2456764.0\Applications\EngWeb\Dev\src\EngWeb.Core\BillOfDocuments\BillOfDocumentsDataAccess.fs(14,27): error FS3033: The type provider 'FSharp.Data.SqlProgrammabilityProvider' reported an error: Could not load file or assembly 'System.Data.SqlClient, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context. (0x80131058)
I am using FSharp.Data.SqlClient version 2.0.6 and System.Data.SqlClient Version 4.8.1 and the FSharp.Core version 4.7.0
Any help with this issue will be appreciated

Upgrade packages WebApi with odata, ver 3.7 ODataModelBuilder reference issues

I'm trying to upgrade my application(MVC) packges from v2.3 to latest v 3.7
Issues i'm facing is the ODataModelBuilder cannot be resolved any more as it is looking for the system.web.odata and the new version installed by package manger due to dependancies is Microsoft.AspNet.OData.
It seems the AbpWebApiODataModule still rederences the System.Web.Odata?
public override void PreInitialize()
{
Configuration.Modules.AbpWebApi().HttpConfiguration.Count().Filter().OrderBy().Expand().Select().MaxTop(null);
Configuration.Modules.AbpWebApiOData().MapAction = configuration =>
{
configuration.Modules.AbpWebApi().HttpConfiguration.MapODataServiceRoute("odata", "odata", configuration.Modules.AbpWebApiOData().ODataModelBuilder.GetEdmModel());
};
var builder = Configuration.Modules.AbpWebApiOData().ODataModelBuilder;
}
The type 'ODataConventionModelBuilder' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Web.OData, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
It seems to be an issue for Abp.WebApi at aspnetboilerplate/issues/2670
The fix has been released with v3.8

Could not load file or assembly 'Serilog.FullNetFx, Version=1.5.0.0'

I have .Net 4.5.2 application and I have installed Serilog 2.1.0 and Serilog.Sinks.MongoDB 2.0.19 I have configured sink as
var log = new Seri.LoggerConfiguration()
.WriteTo.MongoDBCapped("mongodb://localhost:27017/test",collectionName: "logs")
.CreateLogger();
However I am getting error
Could not load file or assembly 'Serilog.FullNetFx, Version=1.5.0.0,
Culture=neutral, PublicKeyToken=24c2f752a8e58a10' or one of its
dependencies. The system cannot find the file
specified.":"Serilog.FullNetFx, Version=1.5.0.0, Culture=neutral,
PublicKeyToken=24c2f752a8e58a10
The MongoDB sink was only updated a day ago to support Serilog 2.0. You need to run:
Update-Package Serilog.Sinks.MongoDB

Precompile an ASP.NET application - i am getting Errors

When i build my project targeting .NET 4.0 in visual Studio 2010, i get the following Warning but with no any other error or warning, so the projects runs.
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1605,5): warning MSB3247: Found conflicts between different versions of the same dependent assembly.
AssemblyFoldersEx location: "{Registry:Software\Microsoft.NETFramework,v4.0,AssemblyFoldersEx}"
However, i cannot recompile the project with aspnet_compiler
***Microsoft (R) ASP.NET Compilation Tool version 4.0.30319.18408
Utility to precompile an ASP.NET application
Copyright (C) Microsoft Corporation. All rights reserved.
(0): warning : The following assembly has dependencies on a version of the .NET Framework that is higher than the target and might not load correctly during runtime causing a failure: myProjectName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null. The dependencies are: System.DirectoryServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a. You should either ensure that the dependent assembly is correct for the target framework, or ensure that the target framework you are addressing is that of the dependent assembly.
d:\Projects\Release\SourceCode\web.config(55): warning CS0108: 'ProfileCommon.GetProfile(string)' hides inherited member 'myProjectName.Core.ProfileCommon.GetProfile(string)'. Use the new keyword if hiding was intended.
c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\ec305f94\ca5ad86b\App_Web_i51pzwht.0.cs(28): error CS0234: The type or namespace name 'myModel' does not exist in the namespace 'MedicalService.ViewModel' (are you missing an assembly reference?)*
This post Resolving MSB3247 - Found conflicts between different versions of the same dependent assembly lead me to the utility below which helped me solve the issue.
http://mikehadlow.blogspot.co.uk/2011/02/asmspy-little-tool-to-help-fix-assembly.html

Error creating a DevExpress controls for ASP.NET MVC empty project manually

I am using Visual Web Developer 2010 Express. I need to use DevExpress controls for an ASP.NET MVC 4 project.
So, I downloaded DevExpress Universal Edition something that has ASP.NET MVC controls.
Since I do not see a DevExpress ASP.NET MVC Empty project template, I am manually creating one following the instructions provided here:
http://documentation.devexpress.com/#AspNet/CustomDocument8163
However, when I start my application, I get this yellow screen of death that says:
Configuration Error
Description: An error occurred during the processing of a configuration file required
to service this request. Please review the specific error details below and modify
your configuration file appropriately.
Parser Error Message: Could not load file or assembly 'DevExpress.Data.v12.2,
Version=12.2.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a' or one of its
dependencies. The system cannot find the file specified.
Source Error:
Line 39: <compilation debug="true" targetFramework="4.0">
Line 40: <assemblies>
Line 41: <add assembly="DevExpress.Data.v12.2, Version=12.2.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
Line 42: <add assembly="DevExpress.Web.v12.2, Version=12.2.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
Line 43: <add assembly="DevExpress.Web.ASPxHtmlEditor.v12.2, Version=12.2.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
Source File: C:\Users\computer\Documents\Visual Studio 2010\Projects\MvcApplication5\MvcApplication5\web.config Line: 41
Assembly Load Trace: The following information can be helpful to determine why the assembly 'DevExpress.Data.v12.2, Version=12.2.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a' could not be loaded.
=== Pre-bind state information ===
LOG: User = computer-VAIO\computer
LOG: DisplayName = DevExpress.Data.v12.2, Version=12.2.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
(Fully-specified)
LOG: Appbase = file:///C:/Users/computer/Documents/Visual Studio 2010/Projects/MvcApplication5/MvcApplication5/
LOG: Initial PrivatePath = C:\Users\computer\Documents\Visual Studio 2010\Projects\MvcApplication5\MvcApplication5\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\computer\Documents\Visual Studio 2010\Projects\MvcApplication5\MvcApplication5\web.config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: DevExpress.Data.v12.2, Version=12.2.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
LOG: Attempting download of new URL file:///C:/Users/computer/AppData/Local/Temp/Temporary ASP.NET Files/root/8847955d/8ce8b26b/DevExpress.Data.v12.2.DLL.
LOG: Attempting download of new URL file:///C:/Users/computer/AppData/Local/Temp/Temporary ASP.NET Files/root/8847955d/8ce8b26b/DevExpress.Data.v12.2/DevExpress.Data.v12.2.DLL.
LOG: Attempting download of new URL file:///C:/Users/computer/Documents/Visual Studio 2010/Projects/MvcApplication5/MvcApplication5/bin/DevExpress.Data.v12.2.DLL.
LOG: Attempting download of new URL file:///C:/Users/computer/Documents/Visual Studio 2010/Projects/MvcApplication5/MvcApplication5/bin/DevExpress.Data.v12.2/DevExpress.Data.v12.2.DLL.
LOG: Attempting download of new URL file:///C:/Users/computer/AppData/Local/Temp/Temporary ASP.NET Files/root/8847955d/8ce8b26b/DevExpress.Data.v12.2.EXE.
LOG: Attempting download of new URL file:///C:/Users/computer/AppData/Local/Temp/Temporary ASP.NET Files/root/8847955d/8ce8b26b/DevExpress.Data.v12.2/DevExpress.Data.v12.2.EXE.
LOG: Attempting download of new URL file:///C:/Users/computer/Documents/Visual Studio 2010/Projects/MvcApplication5/MvcApplication5/bin/DevExpress.Data.v12.2.EXE.
LOG: Attempting download of new URL file:///C:/Users/computer/Documents/Visual Studio 2010/Projects/MvcApplication5/MvcApplication5/bin/DevExpress.Data.v12.2/DevExpress.Data.v12.2.EXE.
It looks like the DLL versions I have and the ones mentioned on that page are different. Please help.
I ran my project through their project converter which scans your references and web.config files and upgrades the entries to reflect the latest DLL's (if the ones you have are later than the ones you are pointing to in the web.config file), which was the case for me because I just copied the references from that page.
It says you're missing the data assembly. You seem to be using an old version. Download the latest version as there is an empty project template in the DevExpress project wizard.
Also, contact the DevExpress support team and they can help you quicker.
Please take a look at this:
How to: Manually Register DevExpress Extensions to Start Using Them in an MVC Web Application

Resources