Today I did a larger data import into a firebird 2.5.6 database and I got this exception:
System.Data.Entity.Core.EntityCommandExecutionException: An error occurred while executing the command definition. See the inner exception for details. ---> FirebirdSql.Data.FirebirdClient.FbException: too many open handles to database ---> FirebirdSql.Data.Common.IscException: too many open handles to database
bei FirebirdSql.Data.Client.Managed.Version10.GdsDatabase.ProcessResponse(IResponse response) in C:\Users\Jiri\Documents\devel\NETProvider\working\Provider\src\FirebirdSql.Data.FirebirdClient\Client\Managed\Version10\GdsDatabase.cs:Zeile 641.
bei FirebirdSql.Data.Client.Managed.Version10.GdsDatabase.ReadResponse() in C:\Users\Jiri\Documents\devel\NETProvider\working\Provider\src\FirebirdSql.Data.FirebirdClient\Client\Managed\Version10\GdsDatabase.cs:Zeile 673.
bei FirebirdSql.Data.Client.Managed.Version10.GdsDatabase.ReadGenericResponse() in C:\Users\Jiri\Documents\devel\NETProvider\working\Provider\src\FirebirdSql.Data.FirebirdClient\Client\Managed\Version10\GdsDatabase.cs:Zeile 681.
bei FirebirdSql.Data.Client.Managed.Version11.GdsStatement.Prepare(String commandText) in C:\Users\Jiri\Documents\devel\NETProvider\working\Provider\src\FirebirdSql.Data.FirebirdClient\Client\Managed\Version11\GdsStatement.cs:Zeile 80.
bei FirebirdSql.Data.FirebirdClient.FbCommand.Prepare(Boolean returnsSet) in C:\Users\Jiri\Documents\devel\NETProvider\working\Provider\src\FirebirdSql.Data.FirebirdClient\FirebirdClient\FbCommand.cs:Zeile 1169.
bei FirebirdSql.Data.FirebirdClient.FbCommand.ExecuteCommand(CommandBehavior behavior, Boolean returnsSet) in C:\Users\Jiri\Documents\devel\NETProvider\working\Provider\src\FirebirdSql.Data.FirebirdClient\FirebirdClient\FbCommand.cs:Zeile 1190.
bei FirebirdSql.Data.FirebirdClient.FbCommand.ExecuteReader(CommandBehavior behavior) in C:\Users\Jiri\Documents\devel\NETProvider\working\Provider\src\FirebirdSql.Data.FirebirdClient\FirebirdClient\FbCommand.cs:Zeile 527.
--- Ende der internen Ausnahmestapelüberwachung ---
bei FirebirdSql.Data.FirebirdClient.FbCommand.ExecuteReader(CommandBehavior behavior) in C:\Users\Jiri\Documents\devel\NETProvider\working\Provider\src\FirebirdSql.Data.FirebirdClient\FirebirdClient\FbCommand.cs:Zeile 533.
bei FirebirdSql.Data.FirebirdClient.FbCommand.ExecuteDbDataReader(CommandBehavior behavior) in C:\Users\Jiri\Documents\devel\NETProvider\working\Provider\src\FirebirdSql.Data.FirebirdClient\FirebirdClient\FbCommand.cs:Zeile 639.
bei System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
bei System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.<Reader>b__c(DbCommand t, DbCommandInterceptionContext`1 c)
bei System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext,TResult](TTarget target, Func`3 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed)
bei System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.Reader(DbCommand command, DbCommandInterceptionContext interceptionContext)
bei System.Data.Entity.Internal.InterceptableDbCommand.ExecuteDbDataReader(CommandBehavior behavior)
bei System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
bei System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)
--- Ende der internen Ausnahmestapelüberwachung ---
bei System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)
bei System.Data.Entity.Core.Objects.Internal.ObjectQueryExecutionPlan.Execute[TResultType](ObjectContext context, ObjectParameterCollection parameterValues)
bei System.Data.Entity.Core.Objects.ObjectQuery`1.<>c__DisplayClass7.<GetResults>b__6()
bei System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess)
bei System.Data.Entity.Core.Objects.ObjectQuery`1.<>c__DisplayClass7.<GetResults>b__5()
bei System.Data.Entity.Infrastructure.DefaultExecutionStrategy.Execute[TResult](Func`1 operation)
bei System.Data.Entity.Core.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
bei System.Data.Entity.Core.Objects.ObjectQuery`1.<System.Collections.Generic.IEnumerable<T>.GetEnumerator>b__0()
bei System.Data.Entity.Internal.LazyEnumerator`1.MoveNext()
bei System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
bei System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.<GetElementFunction>b__1[TResult](IEnumerable`1 sequence)
bei System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.ExecuteSingle[TResult](IEnumerable`1 query, Expression queryRoot)
bei System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.System.Linq.IQueryProvider.Execute[TResult](Expression expression)
bei System.Data.Entity.Internal.Linq.DbQueryProvider.Execute[TResult](Expression expression)
bei System.Linq.Queryable.FirstOrDefault[TSource](IQueryable`1 source)
Can someone explain what this too many open handles to database means? I never saw this before and searching in google only shows 1 old entry.
The error isc_too_many_handles or error 335544761 means what it says: you use too many handles.
Looking at the Firebird 3 code, server.cpp (search for isc_too_many_handles), this error is raised if Firebird cannot allocate a handle for a statement, transaction, blob, or 'request' because you already have 65000 (MAX_OBJCT_HANDLES) handles allocated and in use on a single connection. Note that this number is for all handles on the connection together (not per type).
This can happen if you do too much of the following:
create new statement handles without dropping (closing) statement handles you no longer need,
start transactions but never commit or rollback (which deallocates the handle),
open blobs without closing them (or opening a lot of blobs at once), and
start 'requests' without deallocating them.
AFAIK these 'requests' are used for embedded SQL support and some internal parts of Firebird itself; I'm not exactly sure how and when they are used, so I can't really comment on them. I guess it is not very likely the cause, but maybe when you already have a lot of statements, blobs and transactions these can be the final drop.
You might want to inspect your code for resource leaks, but as you seem to be using Entity Framework, it might also be that the Firebird .net entity framework support or ADO.net driver does something wrong. If you can reproduce it consistently, and you are sure you are closing resources timely, you might want to report a bug (with all necessary code + database to reproduce) on http://tracker.firebirdsql.org/browse/DNET
Related
Since yesterday I'm trying to resolve issues with Facebook SDK for Unity.
I tried it out on completely empty Unity project and everything works fine. I can build it and run on Android device without any problems.
So, I thought I can import package to my game in the same way, but I couldn't be more wrong.
Immediately after import I got this 2 errors:
ArgumentNullException: Argument cannot be null.
Parameter name: path
System.String.StartsWith (System.String value) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/String.cs:1549)
GooglePlayServices.PlayServicesResolver.OnPostprocessAllAssets (System.String[] importedAssets, System.String[] deletedAssets, System.String[] movedAssets, System.String[] movedFromAssetPaths)
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115)
UnityEditor.AssetPostprocessingInternal.PostprocessAllAssets (System.String[] importedAssets, System.String[] addedAssets, System.String[] deletedAssets, System.String[] movedAssets, System.String[] movedFromPathAssets) (at C:/buildslave/unity/build/Editor/Mono/AssetPostprocessor.cs:27)
ArgumentNullException: Argument cannot be null.
Parameter name: path
System.IO.Directory.CreateDirectory (System.String path) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.IO/Directory.cs:75)
GooglePlayServices.PlayServicesResolver.ResolveUnsafe (System.Action`1 resolutionComplete, Boolean forceResolution)
GooglePlayServices.PlayServicesResolver+<Resolve>c__AnonStorey11.<>m__19 ()
GooglePlayServices.PlayServicesResolver.ExecuteNextResolveJob ()
GooglePlayServices.PlayServicesResolver.Resolve (System.Action resolutionComplete, Boolean forceResolution, System.Action`1 resolutionCompleteWithResult)
GooglePlayServices.PlayServicesResolver.AutoResolve ()
UnityEditor.EditorApplication.Internal_CallUpdateFunctions () (at C:/buildslave/unity/build/Editor/Mono/EditorApplication.cs:183)
When I try to run project despite of this errors, I got new ones:
Gradle failed to fetch dependencies.
Failed to run 'C:\GameDev\AbstractRhythm\Temp\PlayServicesResolverGradle\gradlew.bat -b "C:\GameDev\AbstractRhythm\Temp\PlayServicesResolverGradle\PlayServicesResolver.scripts.download_artifacts.gradle" --no-daemon "-PANDROID_HOME=C:\Users\adrso\AppData\Local\Android\Sdk" "-PTARGET_DIR=C:\GameDev\AbstractRhythm\Assets\Plugins\Android" "-PMAVEN_REPOS=" "-PPACKAGES_TO_COPY=com.android.support:support-v4:25.3.1;com.android.support:appcompat-v7:25.3.1;com.android.support:cardview-v7:25.3.1;com.android.support:customtabs:25.3.1"'
stdout:
ERROR: JAVA_HOME is set to an invalid directory: C:\Program Files (x86)\Java\jdk1.7.0_55
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
stderr:
exit code: 1
UnityEngine.Debug:LogError(Object)
Google.Logger:Log(String, LogLevel)
GooglePlayServices.PlayServicesResolver:Log(String, LogLevel)
GooglePlayServices.<GradleResolution>c__AnonStorey14:<>m__20(Result)
GooglePlayServices.<GradleResolution>c__AnonStorey15:<>m__29()
GooglePlayServices.PlayServicesResolver:PumpUpdateQueue()
UnityEditor.EditorApplication:Internal_CallUpdateFunctions()
NullReferenceException: Object reference not set to an instance of an object
GooglePlayServices.AndroidSdkManager+<Create>c__AnonStoreyA.<>m__C (GooglePlayServices.AndroidSdkPackageCollection packages)
GooglePlayServices.SdkManager+<QueryPackages>c__AnonStorey9.<>m__B (GooglePlayServices.Result result)
GooglePlayServices.SdkManagerUtil+<QueryPackages>c__AnonStorey4.<>m__4 (GooglePlayServices.Result result)
GooglePlayServices.CommandLineDialog+ProgressReporter.Update (GooglePlayServices.CommandLineDialog window)
GooglePlayServices.CommandLineDialog.Update ()
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115)
UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:291)
UnityEditor.HostView.Invoke (System.String methodName) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:284)
UnityEditor.HostView.SendUpdate () (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:363)
UnityEditor.EditorApplication.Internal_CallUpdateFunctions () (at C:/buildslave/unity/build/Editor/Mono/EditorApplication.cs:183)
I use: Facebook SDK for Unity version 7.13.0, Unity version 2018.1.0f2, Android API 28, Android SDK Build-Tools 28, Android SDK Platform-Tools 25.0.3, Android SDK Tools 25.2.4, Google Play services 49
Do you have any idea what's going on?
It required few steps to solve this problem:
Compare Assets/Plugins/Android/AndroidManifest.xml of unworking project with empty project that only have Facebook SDK.
Use Assets -> Play Services Resolver -> Android Resolver -> Force Resolve.
Check "Environment variables" in Windows, it turned out I had path to new JDK as well as old - remove old entry.
Make sure you don't have any app using same Facebook app ID on your device, you can only have one at a time.
I hope someone will save time thanks to this :)
I have the following connection string that is used by a generated EF model. It works correctly on my local machine but when I deploy, I get the error below. I have look at the URL referenced many time on SO: http://blogs.teamb.com/craigstuntz/2010/08/13/38628/ and if it has the answer in it, I don't see it for my case.
I'm pasting the error below
<add name="svcodecampEntitiesAllTables" connectionString="metadata=res://*/EFModel.ModelAllTables.csdl|res://*/EFModel.ModelAllTables.ssdl|res://*/EFModel.ModelAllTables.msl;provider=System.Data.SqlClient;provider connection string="data source=.;initial catalog=svcc;integrated security=True;persist security info=True;multipleactiveresultsets=True;application name=EntityFramework"" providerName="System.Data.EntityClient" />
{"message":"An error has occurred.","exceptionMessage":"Unable to load the specified metadata resource.","exceptionType":"System.Data.MetadataException","stackTrace":" at System.Data.Metadata.Edm.MetadataArtifactLoaderCompositeResource.LoadResources(String assemblyName, String resourceName, ICollection`1 uriRegistry, MetadataArtifactAssemblyResolver resolver)\r\n at System.Data.Metadata.Edm.MetadataArtifactLoaderCompositeResource..ctor(String originalPath, String assemblyName, String resourceName, ICollection`1 uriRegistry, MetadataArtifactAssemblyResolver resolver)\r\n at System.Data.Metadata.Edm.MetadataArtifactLoaderCompositeResource.CreateResourceLoader(String path, ExtensionCheck extensionCheck, String validExtension, ICollection`1 uriRegistry, MetadataArtifactAssemblyResolver resolver)\r\n at System.Data.Metadata.Edm.MetadataArtifactLoader.Create(String path, ExtensionCheck extensionCheck, String validExtension, ICollection`1 uriRegistry, MetadataArtifactAssemblyResolver resolver)\r\n at System.Data.Metadata.Edm.MetadataCache.SplitPaths(String paths)\r\n at System.Data.Common.Utils.Memoizer`2.<>c__DisplayClass2.<Evaluate>b__0()\r\n at System.Data.Common.Utils.Memoizer`2.Result.GetValue()\r\n at System.Data.Common.Utils.Memoizer`2.Evaluate(TArg arg)\r\n at System.Data.EntityClient.EntityConnection.GetMetadataWorkspace(Boolean initializeAllCollections)\r\n at System.Data.Objects.ObjectContext.RetrieveMetadataWorkspaceFromConnection()\r\n at System.Data.Objects.ObjectContext..ctor(EntityConnection connection, Boolean isConnectionConstructor)\r\n at System.Data.Objects.ObjectContext..ctor(EntityConnection connection)\r\n at System.Data.Entity.Internal.InternalConnection.CreateObjectContextFromConnectionModel()\r\n at System.Data.Entity.Internal.LazyInternalConnection.CreateObjectContextFromConnectionModel()\r\n at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()\r\n at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)\r\n at System.Data.Entity.Internal.Linq.InternalSet`1.Initialize()\r\n at System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext()\r\n at System.Data.Entity.Infrastructure.DbQuery`1.System.Linq.IQueryable.get_Provider()\r\n at System.Linq.Queryable.Select[TSource,TResult](IQueryable`1 source, Expression`1 selector)\r\n at WebAPI.rest.AttendeesDashboardController.Get(String userSearch, Nullable`1 presentersOnly, Nullable`1 currentCodeCampYearOnly, Nullable`1 start, Nullable`1 limit) in c:\\VCProject\\SVCodeCampWeb\\WebAPI\\rest\\AttendeesDashboardController.cs:line 97\r\n at lambda_method(Closure , Object , Object[] )\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass13.<GetExecutor>b__c(Object instance, Object[] methodParameters)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.<>c__DisplayClass5.<ExecuteAsync>b__4()\r\n at System.Threading.Tasks.TaskHelpers.RunSynchronously[TResult](Func`1 func, CancellationToken cancellationToken)"}
I had this problem too. I fixed it by explicitly naming the assembly that contains the model.
So, if your model is in "Product.DAL.dll", instead of:
metadata=res://*/EFModel.ModelAllTables.csdl|...
put:
metadata=res://Product.DAL/EFModel.ModelAllTables.csdl|...
for all 3 metadata resources
You must add reference to your project that contains the edmx diagram and change the connection string in the Nunit project
Change
<add name="ContainerName" connectionString="metadata=res://*/Diagram.csdl|re.....
By the name of the library in the 3 places in the metadata
<add name="ContainerName"connectionString="metadata=res://File.Data/Diagram.csdl|res://File.Data/Diagra...
"File.Data" is File.Data.dll, library generated by the project that contains the diagram
I have the same problem and solved by running custom tool. Right click on Model.tt file and click on run custom tool and repeat the same for context.tt file and Model.edmx file. Rebuilding the application will works.
I am using Code First to create a table.
I created the class, the mapping file and issued the add-migration command in nuget and then the update-database command
I then changed the class and like an idiot deleted the table.
I deleted the migration class file
I issued a add-migration command
When I issue the update-database command I get the following error:
System.Data.SqlClient.SqlException (0x80131904): Cannot find the
object "dbo.CorrectiveActionPlan" because it does not exist or you do
not have permissions. at
System.Data.SqlClient.SqlConnection.OnError(SqlException exception,
Boolean breakConnection, Action1 wrapCloseInAction) at
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException
exception, Boolean breakConnection, Action1 wrapCloseInAction) at
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject
stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) at
System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior,
SqlCommand cmdHandler, SqlDataReader dataStream,
BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject
stateObj, Boolean& dataReady) at
System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String
methodName, Boolean async, Int32 timeout) at
System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource1
completion, String methodName, Boolean sendToPipe, Int32 timeout,
Boolean asyncWrite) at
System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at
System.Data.Entity.Migrations.DbMigrator.ExecuteSql(DbTransaction
transaction, MigrationStatement migrationStatement) at
System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.ExecuteSql(DbTransaction
transaction, MigrationStatement migrationStatement) at
System.Data.Entity.Migrations.DbMigrator.ExecuteStatements(IEnumerable1
migrationStatements) at
System.Data.Entity.Migrations.Infrastructure.MigratorBase.ExecuteStatements(IEnumerable1
migrationStatements) at
System.Data.Entity.Migrations.DbMigrator.ExecuteOperations(String
migrationId, XDocument targetModel, IEnumerable1 operations, Boolean
downgrading, Boolean auto) at
System.Data.Entity.Migrations.DbMigrator.ApplyMigration(DbMigration
migration, DbMigration lastMigration) at
System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.ApplyMigration(DbMigration
migration, DbMigration lastMigration) at
System.Data.Entity.Migrations.DbMigrator.Upgrade(IEnumerable1
pendingMigrations, String targetMigrationId, String lastMigrationId)
at
System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.Upgrade(IEnumerable1
pendingMigrations, String targetMigrationId, String lastMigrationId)
at System.Data.Entity.Migrations.DbMigrator.Update(String
targetMigration) at
System.Data.Entity.Migrations.Infrastructure.MigratorBase.Update(String
targetMigration) at
System.Data.Entity.Migrations.Design.ToolingFacade.UpdateRunner.RunCore()
at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.Run()
ClientConnectionId:a6e92a35-cc9e-4867-97a5-0a274081d853 Cannot find
the object "dbo.CorrectiveActionPlan" because it does not exist or you
do not have permissions.
How do I force EF to recreate the table?
I found my answer.
I deleted the row in [dbo].[__MigrationHistory] that corresponded to my Migration
I then deleted the new migration file
I re-ran add-migration
and then re-ran update-database -verbose
There are a few options I keep in my arsenal for code-first migrations and they depend on why you need to delete tables or delete the records. Here is my methods:
If you modified the models and the mappings are causing an error that prevents you from not being able to update the tables you could Delete the entire database using SQL Management Server Studio & Delete the Migration folder You may want to save a script to re-populate your test data using an sql script or save your Configuration.cs file and when you execute the update database command the data will be re-populated.
Here is an example of script for a stored procedure to just drop table data:
USE [DatabaseName]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[sp_DeleteAllYardPenaltyRecords]
AS
EXEC sp_MSForEachTable 'ALTER TABLE ? NOCHECK CONSTRAINT ALL'
EXEC sp_MSForEachTable 'ALTER TABLE ? DISABLE TRIGGER ALL'
EXEC sp_MSForEachTable 'DELETE FROM ?'
EXEC sp_MSForEachTable 'ALTER TABLE ? CHECK CONSTRAINT ALL'
EXEC sp_MSForEachTable 'ALTER TABLE ? ENABLE TRIGGER ALL'
EXEC sp_MSFOREACHTABLE 'SELECT * FROM ?'
If you just want to drop the data you can use the package manager console command: PM> Update-Database -TargetMigration $InitialDatabase & delete the migration file created ie: '201502210525393_example_with_error.cs' and re-run 'Add-Migration new_example.cs' again. This puts the database back to its initial snapshot
Or you could use your method: delete the row in [dbo].[__MigrationHistory] & migration file ie: '201502210525393_example_with_error.cs' then re-run add-migration and update-database
You could just drop the database then from the package manager console run the 'update-database' command, all would be recreated including whatever updates you made.
Today EF4.3.1 released.
http://blogs.msdn.com/b/adonet/archive/2012/02/29/ef4-3-1-and-ef5-beta-1-available-on-nuget.aspx.
Follow the blog: http://thedatafarm.com/blog/data-access/using-ef-migrations-with-an-existing-database/. I firstly run:add-migration initial but throw exception as below and no create folder migrations:
PM> add-migration initial
System.Reflection.TargetInvocationException: 调用的目标发生了异常。 ---> System.ArgumentException: 参数不正确。 (异常来自 HRESULT:0x80070057 (E_INVALIDARG))
--- 内部异常堆栈跟踪的结尾 ---
在 System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters)
在 System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
在 System.Management.Automation.ComMethod.InvokeMethod(PSMethod method, Object[] arguments)
调用的目标发生了异常。
thus, I run Enable-migrations firstly. the folder migrations with Configuration.cs created.
I checked the database, under system tables without dbo._migrationhistory table.
then I run add-migration initial again. throw the same exception Mentioned before.
the Domain model in a project and the datacontext in another project which locate in DAL layer.
in my existing database Security there are several table such as role ,user and so on.
but no migration-history table.
there is only Iset Navigators in my datacontext. no match database tables.
My problem is how to get migration-history table and set up migration?
I finally found that if move the project out of solution Folder. it will work fine. maybe it's a bug.
When I try to use nunit-console.exe to run all the tests in a solution file as such:
nunit-console.exe MyProject.sln
I get the following exception (shown below). However when run the console runner on ANY of the projects in my folder structure, the runner works just fine and never gives me the following exception. I also am pretty certain that the version of the nunit library that I am linking to is the same as the runner that I am using. Also, my solution doesn't reference any projects that are outside the directory structure containing my .sln file.
Does anyone have any clue what I can do!? :(
Thanks!
Phil
NUnit version 2.5.10.11092
Copyright (C) 2002-2009 Charlie Poole.
Copyright (C) 2002-2004 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov.
Copyright (C) 2000-2002 Philip Craig.
All Rights Reserved.
Runtime Environment -
OS Version: Microsoft Windows NT 6.1.7601 Service Pack 1
CLR Version: 4.0.30319.1 ( Net 4.0 )
ProcessModel: Default DomainUsage: Default
Execution Runtime: net-4.0
Unhandled Exception:
System.IO.FileLoadException: Could not load file or assembly 'nunit.framework, Version=2.5.10.11092, Culture=neutral, Pu
blicKeyToken=96d09a1eb7f44a77' or one of its dependencies. The located assembly's manifest definition does not match the
assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'nunit.framework, Version=2.5.10.11092, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77'
Server stack trace:
at System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount,
IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type)
at System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInsta
ntiationContext, RuntimeTypeHandle[] methodInstantiationContext)
at System.ModuleHandle.ResolveTypeHandle(Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHa
ndle[] methodInstantiationContext)
at System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethod
Arguments)
at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope
, Assembly& lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilte
rType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, IRuntimeMeth
odInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken,
Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecorate
dTargetSecurityTransparent)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeType type, RuntimeType caType, Boolean inherit)
at NUnit.Core.CoreExtensions.InstallAdhocExtensions(Assembly assembly)
at NUnit.Core.Builders.TestAssemblyBuilder.Load(String path)
at NUnit.Core.Builders.TestAssemblyBuilder.Build(String assemblyName, Boolean autoSuites)
at NUnit.Core.Builders.TestAssemblyBuilder.Build(String assemblyName, String testName, Boolean autoSuites)
at NUnit.Core.TestSuiteBuilder.Build(TestPackage package)
at NUnit.Core.SimpleTestRunner.Load(TestPackage package)
at NUnit.Core.ProxyTestRunner.Load(TestPackage package)
at NUnit.Core.ProxyTestRunner.Load(TestPackage package)
at NUnit.Core.RemoteTestRunner.Load(TestPackage package)
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server,
Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExec
uteInContext)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at NUnit.Core.TestRunner.Load(TestPackage package)
at NUnit.Util.TestDomain.Load(TestPackage package)
at NUnit.ConsoleRunner.ConsoleUi.Execute(ConsoleOptions options)
at NUnit.ConsoleRunner.Runner.Main(String[] args)
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
Try using the Fusion Log Viewer to see what assembly is failing to load. It should tell you not only what file it is failing on, but where it tried looking for that file.
In my case nunit-console.exe did not respect the assembly redirection from web|app.config. unless you provide /domain=multiple
My Problem:
EntityFrameworkTesting.Moq -> requests Moq, Version=4.2.1409.1722
I had already a newer assembly referenced.
The solution for me was to add /domain=multiple parameter. see the NUnit docs
So I run:
D:\tools\NUnit-2.6.4\bin\nunit-console.exe %SOLUTION_PATH%\Project.sln /config:Release /framework:net-4.0 /domain=multiple /xml=nunit-result.xml