Я работаю с MySQL и .Net EntityFramework 4, используя подход Code First. Версия коннектора mysql - 6.4.3.
Когда я запускаю проект в первый раз, мой инициализатор пытается «DropCreateDatabaseAlways». База данных создается так же, как и все таблицы. Затем выдается следующее исключение.
<code>Column length too big for column 'ModelHash' (max = 21845); use BLOB or TEXT instead
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.</p>
<p>Exception Details: MySql.Data.MySqlClient.MySqlException: Column length too big for column 'ModelHash' (max = 21845); use BLOB or TEXT instead</p>
<p>Source Error:</p>
<p>Line 38: public virtual List GetAll()
Line 39: {
Line 40: return dbSet.ToList();
Line 41: }
Line 42: </p>
<p>Source File: C:\Users\Andrew\Documents\Visual Studio 2010\Projects\SearchCore\OnlineID.DAL\GlobalGatewayRepository.cs Line: 40</p>
<p>Stack Trace:</p>
<p>[MySqlException (0x80004005): Column length too big for column 'ModelHash' (max = 21845); use BLOB or TEXT instead]
MySql.Data.MySqlClient.MySqlStream.ReadPacket() +198
MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int32& insertedId) +73
MySql.Data.MySqlClient.Driver.GetResult(Int32 statementId, Int32& affectedRows, Int32& insertedId) +20
MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force) +100
MySql.Data.MySqlClient.MySqlDataReader.NextResult() +836
MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior) +1399
MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery() +36
MySql.Data.MySqlClient.MySqlScript.Execute() +551
MySql.Data.MySqlClient.MySqlProviderServices.DbCreateDatabase(DbConnection connection, Nullable<code>1 commandTimeout, StoreItemCollection storeItemCollection) +260
System.Data.Objects.ObjectContext.CreateDatabase() +84
System.Data.Entity.Internal.DatabaseOperations.CreateIfNotExists(ObjectContext objectContext) +28
System.Data.Entity.Database.CreateIfNotExists() +53
System.Data.Entity.DropCreateDatabaseAlways</code>1.InitializeDatabase(TContext context) +233
System.Data.Entity.<>c__DisplayClass2<code>1.<SetInitializerInternal>b__0(DbContext c) +75
System.Data.Entity.Internal.<>c__DisplayClass5.<PerformDatabaseInitialization>b__3() +19
System.Data.Entity.Internal.InternalContext.PerformInitializationAction(Action action) +72
System.Data.Entity.Internal.InternalContext.PerformDatabaseInitialization() +169
System.Data.Entity.Internal.LazyInternalContext.<InitializeDatabase>b__4(InternalContext c) +7
System.Data.Entity.Internal.RetryAction</code>1.PerformAction(TInput input) +118
System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(Action<code>1 action) +190
System.Data.Entity.Internal.LazyInternalContext.InitializeDatabase() +73
System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) +27
System.Data.Entity.Internal.Linq.InternalSet</code>1.Initialize() +62
System.Data.Entity.Internal.Linq.InternalSet<code>1.GetEnumerator() +15
System.Data.Entity.Infrastructure.DbQuery</code>1.System.Collections.Generic.IEnumerable.GetEnumerator() +40
System.Collections.Generic.List<code>1..ctor(IEnumerable</code>1 collection) +315
System.Linq.Enumerable.ToList(IEnumerable<code>1 source) +58
OnlineID.DAL.GlobalGatewayRepository</code>1.GetAll() in C:\Users\Andrew\Documents\Visual Studio 2010\Projects\SearchCore\OnlineID.DAL\GlobalGatewayRepository.cs:40
OnlineID.BAL.AccountService.GetAccounts() in C:\Users\Andrew\Documents\Visual Studio 2010\Projects\SearchCore\OnlineID.BAL\AccountService.cs:32
OnlineID.Website.Controllers.AccountManagement.AccountManagementController.Index() in C:\Users\Andrew\Documents\Visual Studio 2010\Projects\SearchCore\OnlineID.Website\Controllers\AccountManagement\AccountManagementController.cs:29
lambda_method(Closure , ControllerBase , Object[] ) +62
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +17
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary<code>2 parameters) +208
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary</code>2 parameters) +27
System.Web.Mvc.<>c_<em>DisplayClass15.b</em>_12() +55
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func<code>1 continuation) +263
System.Web.Mvc.<>c__DisplayClass17.<InvokeActionMethodWithFilters>b__14() +19
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList</code>1 filters, ActionDescriptor actionDescriptor, IDictionary<code>2 parameters) +191
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +343
System.Web.Mvc.Controller.ExecuteCore() +116
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +97
System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10
System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +37
System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +21
System.Web.Mvc.Async.<>c__DisplayClass8</code>1.b__7(IAsyncResult <em>) +12
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
System.Web.Mvc.<>c</em>_DisplayClasse.b_<em>d() +50
System.Web.Mvc.SecurityUtil.b</em>_0(Action f) +7
System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +60
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8920029
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184
Я не уверен, что это за столбец "ModelHash", поскольку он не существует в моих моделях.
Спасибо,
AFrieze
Я определил местоположение этого столбца ModelHash, он находится в таблице EdmMetadata, которая используется для отслеживания изменений. Ошибка, которую я испытываю, может быть устранена путем добавления следующего modelBuilder.Conventions.Remove (); Есть ли способ использовать EdmMetadata с MySQL тогда?