简体   繁体   English

实体框架“代码优先”未创建数据库表

[英]Entity Framework “Code First” not creating database tables

I've created my objects in ASP.NET MVC4, and after running the application, only UserProfile table is auto created, not the other one corresponding my class. 我已经在ASP.NET MVC4中创建了我的对象,并且在运行该应用程序之后,仅自动创建了UserProfile表,而没有另一个对应于我的类。

Followed this advice: Entity Framework 4.1 Code First not creating tables and got this error: 遵循以下建议: Entity Framework 4.1 Code首先未创建表并出现此错误:

Model compatibility cannot be checked because the database does not contain model metadata. 由于数据库不包含模型元数据,因此无法检查模型兼容性。 Model compatibility can only be checked for databases created using Code First or Code First Migrations. 只能检查使用Code First或Code First迁移创建的数据库的模型兼容性。

Question 1: What is the correct way to do this in Code First approach? 问题1:在“代码优先”方法中执行此操作的正确方法是什么?

Question 2: Why is the built-in UserProfile created, and not the table for my object? 问题2:为什么创建内置的UserProfile,而不创建对象的表? What makes the difference? 有什么区别?

Please read my answer here ... same situation I think. 在这里阅读我的答案...我认为情况相同。 UserProfile table created, others not created. 已创建UserProfile表,未创建其他表。 My guess is that you've switched to an actual MSSQL DB and not a local DB, but have not pointed your WebSecurity DB initialization to the new database. 我的猜测是您已切换到实际的MSSQL DB而不是本地数据库,但尚未将WebSecurity DB初始化指向新数据库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Code First Entity Framework不使用表创建数据库 - Code First Entity Framework does not create database with tables 在实体框架中使用数据库优先实体和代码优先实体 - Using database first entity with code first entity in entity framework 首先使用现有数据库的实体框架代码 - entity framework code first using existing database 代码优先实体框架未建立数据库 - Code First Entity Framework not building database 实体框架代码优先使用 Oracle 数据库 - Entity Framework Code First With Oracle Database 使用Entity Framework Code First开发,我能否在现有数据库中创建一个或多个表? - Using Entity Framework Code First Development, can I get it to create a table or tables in an existing database? 实体框架7将现有数据库表转换为ASP.NET MVC中的代码第一类6 - entity framework 7 Convert existing database tables to code first classes in asp.net mvc 6 如何首先使用实体​​框架数据库维护表中的多重关系? - How to maintain Multiple Relation In tables Using Entity Framework Database first? 是否可以将数据库优先模型和代码优先模型与实体框架混合使用? - Is it possible to mix database first and code first models with entity framework? 我的数据库不会先使用实体​​框架代码进行播种 - my database won't seed using entity framework code first
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM