首页 > 数据库 >EF CodeFirst mysql 迁移异常Unable to create a 'DbContext' of type

EF CodeFirst mysql 迁移异常Unable to create a 'DbContext' of type

时间:2024-01-05 18:44:56浏览次数:42  
标签:CodeFirst create ChangeTracking EntityFrameworkCore Unable type Microsoft

问题过程

终端执行 dotnet ef migrations add init
出现如下错误:

Pomelo.EntityFrameworkCore.MySql
Microsoft.EntityFrameworkCore.Tools
Unable to create a 'DbContext' of type ''. The exception 'Method not found: 'Void CoreTypeMappingParameters..ctor(System.Type, Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter, Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer, Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer, Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer, System.Func`3<Microsoft.EntityFrameworkCore.Metadata.IProperty,Microsoft.EntityFrameworkCore.Metadata.IEntityType,Microsoft.EntityFrameworkCore.ValueGeneration.ValueGenerator>)'.' was thrown while attempting to create an instance. For the different patterns supported at design time, see https://go.microsoft.com/fwlink/?linkid=851728

解决

在nuget上重新搜了相关的包,然后配置如下:

<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="8.0.0-beta.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.0">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>

问题得到解决:

标签:CodeFirst,create,ChangeTracking,EntityFrameworkCore,Unable,type,Microsoft
From: https://www.cnblogs.com/leafroc/p/17947840

相关文章

  • MathType报错问题
    MathType报错问题解决MathTypehasdetectedanerrorinAutoExecCls.Main:文件未找到:MathPage.WLL.Pleasesaveyou报错信息:MathTypehasdetectedanerrorinAutoExecCls.Main:文件未找到:MathPage.WLL.PleasesaveyourdocumentandreportthiserrortoDesignS......
  • 数据反序列化参数TypeReference
    使用jackson或者fastjson将json字符串反序列化成对象(以fastjson为例)TypeReference<AjaxResult<List<Person>>>typeReference=newTypeReference<AjaxResult<List<Person>>>(){};Stringjson="{\"code\":200,\"success\......
  • 在TypeScript中重命名类型索引?
    在TypeScript中,要重命名类型索引,你可以使用TypeScript的类型别名或接口来实现。下面是两种常见的方法:1.使用类型别名(TypeAliases):类型别名允许你为一个类型定义一个别名,通过使用关键字type来创建。你可以在别名中定义索引类型,并为该类型定义一个新的名称。```typescripttypeMy......
  • [转帖]SecurityProtocolType 枚举
    https://learn.microsoft.com/zh-cn/dotnet/api/system.net.securityprotocoltype?view=net-8.0 命名空间:System.Net程序集:System.Net.ServicePoint.dll指定Schannel安全包支持的安全协议。此枚举支持其成员值的按位组合。C#复制 [System.Flags]publicenum......
  • 【译】如何提高我的 TypeScript 技能
    在这篇文章中,我将向您展示我如何在TypeScript中提高自己的技能。我会向您介绍5个令人满意的操作符,这将帮助您更好地理解TypeScript和如何使用它。以下是我将要介绍的操作符:非空断言操作符可选链操作符空合并操作符明确类型断言明确类型转换1.非空断言操作符非空断言操作符是......
  • erlang -type 以及-spec 使用
    很多时候我们编写的模块方法需要明确的参数类型,方便使用,-type以及-spec就提供了此能力参考使用app.erl-module(app).-export([myadd/1,mydemo/1]).-typeadd()::{integer(),integer()}.-specmyadd(add())->integer().myadd(Args)->{A,B}=Args,A+......
  • 前端VUE JS if (!this.form.typeId)什么意思,包括数字0吗
    这行代码是在检查this.form对象的typeId属性是否为假值。如果typeId是假值(比如null、undefined、false、0、NaN或空字符串""),那么条件将被视为true。这通常用于检查对象属性是否存在或是否被设置为一个真实的值。数字0也包括吗?是的,数字0也被视为假值。在JavaScript中,条......
  • [Typescript] This type
    Sometimeswehaveafree-standingfunctionthathasastrongopinionaroundwhatthiswillendupbeing,atthetimeitisinvoked.Forexample,ifwehadaDOMeventlistenerforabutton:<buttononClick="myClickHandler">ClickMe!</b......
  • 解决 typescript node tsx 的兼容问题
    问题在项目中使用typescript+tsx+node存在各种兼容问题,包括:[esbuildError]:Top-levelawaitiscurrentlynotsupportedwiththe"cjs"outputformatCannotfindmodule'X'.Didyoumeantosetthe'moduleResolution'optionto'......
  • HTTP协议安全头部X-Content-Type-Options引入的问题
    本文于2016年4月完成,发布在个人博客网站上。考虑个人博客因某种原因无法修复,于是在博客园安家,之前发布的文章逐步搬迁过来。前段时间测试MM反馈了一个问题,在富文本编辑器里上传的图片无法正常呈现。因为Jackie在本机的环境上没有观察类似的现象,而恰好那天测试环境的某个重要配......