[英]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.