gpt4 book ai didi

mysql - 如何使用 MySQL 配置 MvcMusicStore .Net WebApp?

转载 作者:行者123 更新时间:2023-11-29 01:04:24 37 4
gpt4 key购买 nike

我完全迷路了。我正在尝试使用 MySQL 设置 MvcMusicStore .Net 应用程序 ( http://mvcmusicstore.codeplex.com/ ),但在编译项目时出现了几个错误;

我已在 http://dev.mysql.com 阅读文档关于在 MySQL 中使用 .Net Entity Framework 但是我是 EF 的初学者,这些是我没有成功的步骤:

  • 我已经安装了 MySQL Server 5.5

  • http://mvcmusicstore.codeplex.com/downloads/get/238258 下载了 MvcMusicStore

  • 安装了 MySQL Connector Net 6.4.4 并在 mysql 中创建了数据库:创建数据库 mvcmusicstore/*!40100 字符集 utf8 整理 utf8_general_ci */;

  • 添加了以下对项目 MvcMusicStore 的引用:mysql.data, (mysql.data.cf not added or i get an error), mysql.data.entity, mysql.web(对于每个库,在属性中,选择“true”以复制bin文件夹中的dll)

  • 在“web.config”中替换:

    <connectionStrings>
    <add name="MusicStoreEntities"
    connectionString="Data Source=|DataDirectory|MvcMusicStore.sdf"
    providerName="System.Data.SqlServerCe.4.0"/>
    </connectionStrings>

与:

    <connectionStrings>
<add name="MusicStoreEntities"
connectionString="Server=127.0.0.1; Database=mvc_store; Uid=root; Pwd={* my password *};"
providerName="MySQL Data Provider" />
</connectionStrings>
<system.data>
<DbProviderFactories>
<add name="MySQL Data Provider"
invariant="MySql.Data.MySqlClient"
description=".Net Framework Data Provider for MySQL"
type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.4.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
</DbProviderFactories>
</system.data>
  • cleaned project -> compiled & recompiled, then I got the error:

“为 system.data 创建配置部分处理程序时发生错误:列“InvariantName”被限制为唯一的。值‘MySql.Data.MySqlClient’已经存在。”

所以我用在 How to use MySql and Entity Framework 4.1 code first 找到的代码替换了“dbproviderfactories”部分

    <DbProviderFactories>
<remove invariant="MySql.Data.MySqlClient" />
<add name="MySQL Data Provider"
invariant="MySql.Data.MySqlClient"
description=".Net Framework Data Provider for MySQL"
type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.4.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
</DbProviderFactories>
  • 重新编译后,出现“找不到数据提供者”的错误:

    Details: 
    ArgumentException: Can not find the data provider. Net Framework required. It may not be installed.

    Error in the source code:

    Row 17: ' the albums with the highest count
    Row 18:
    Row 19: Return storeDB.Albums.OrderByDescending(Function(a) a.OrderDetails.Count()).Take(count).ToList()
    Row 20: End Function
    Row 21: End Class

    File: C:\{...}\MvcMusicStore-Completed\MvcMusicStore\Controllers\HomeController.vb Row: 19

    stack:

    [ArgumentException: Can not find the data provider. Net Framework required. It may not be installed.]
    System.Data.Common.DbProviderFactories.GetFactory(String providerInvariantName) +1420503
    System.Data.Entity.Internal.LazyInternalConnection.TryInitializeFromAppConfig(String name) +393
    System.Data.Entity.Internal.LazyInternalConnection.Initialize() +47
    System.Data.Entity.Internal.LazyInternalConnection.get_ConnectionHasModel() +9
    System.Data.Entity.Internal.LazyInternalContext.InitializeContext() +262
    System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) +18
    System.Data.Entity.Internal.Linq.InternalSet`1.Initialize() +63
    System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext() +15
    System.Data.Entity.Infrastructure.DbQuery`1.System.Linq.IQueryable.get_Provider() +37
    System.Linq.Queryable.OrderByDescending(IQueryable`1 source, Expression`1 keySelector) +66
    MvcMusicStore.HomeController.GetTopSellingAlbums(Int32 count) in C:\Users\Max\Desktop\Projects\MvcStore\MvcMusicStore-Completed\MvcMusicStore\Controllers\HomeController.vb:19
    MvcMusicStore.HomeController.Index() in C:\Users\Max\Desktop\Projects\MvcStore\MvcMusicStore-Completed\MvcMusicStore\Controllers\HomeController.vb:10
    lambda_method(Closure , ControllerBase , Object[] ) +96
    System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +17
    System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +208
    System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27
    System.Web.Mvc.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12() +55
    System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +263
    System.Web.Mvc.<>c__DisplayClass17.<InvokeActionMethodWithFilters>b__14() +19
    System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`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`1.<BeginSynchronous>b__7(IAsyncResult _) +12
    System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
    System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +50
    System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__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() +8970061
    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184
    --------------------------------------------------------------------------------
    Microsoft .NET Framework:4.0.30319; ASP.NET:4.0.30319.272

我不知道如何解决它。

提前谢谢你,

最大

最佳答案

您是否记得在您的项目中添加对 MySQL 连接器的引用?

关于mysql - 如何使用 MySQL 配置 MvcMusicStore .Net WebApp?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11275579/

37 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com