ef-migrations

Oracle.ManagedDataAccess.EntityFramework - ORA-01918: user 'dbo' does not exist

百般思念 提交于 2019-12-28 03:05:07
问题 I am trying to implemente code First Migrations with Oracle.ManagedDataAccess 6.121.1.0 provider, but with no success at all. As I am receiving a ORA-code, I am assuming that the connection are been opened successfully. But the Migrations are failing because, maybe, the provider are behaving as a SQL Server, instead of Oracle. I think that beacause it is traying to use 'dbo' as default schema. Here is my web.config settings: <configuration> <configSections> <section name="entityFramework"

Is there any way i can just create a table in SQL Server and then update the migration to my project?

瘦欲@ 提交于 2019-12-25 18:38:32
问题 I have imported database tables from MS SQL Server 2012 and migrated them to Visual Studio 2015 using code-first concept shown in this example. Its working but just now i just added a new table in SQL Server and i wanted to update the DBContext in my project with the new table. I tried entering "add-migration new_table_name" in the Package Manager Console but it didn't work. I understand that i have to code a new model manually in the Models folder of my project, then only that migration will

Refactor EF6 entity to instead of use multiple properties use a complex type

心已入冬 提交于 2019-12-25 16:42:57
问题 I have a class customer that contains address properties, phone properties and fax properties, but I want to take off the address, phone properties to complex types. Does properties are already in the database as columns. [Table("tblCustomer")] public partial class Customer : Entity { [Key] public int CustomerID { get; set; } [StringLength(10)] public string CustomerCode { get; set; } [StringLength(60)] public string AddressLine1 { get; set; } [StringLength(70)] public string AddressLine2 {

Migration “our target project 'xxx' doesn't match your migrations assembly 'xxx'” using aspnet Core 1.0 RC2 -

徘徊边缘 提交于 2019-12-25 07:26:46
问题 I'm trying to build the migration classes for a second DBContext in a assembly. using this command: Add-Migration AlertInitial -c Axper.Data.Persistence.Context.AlertContext and using the "Package Console management" But it fail and give me this error: Your target project 'AxPortal' doesn't match your migrations assembly 'Axper.Data.Persistence'. Either change your target project or change your migrations assembly. Change your migrations assembly by using DbContextOptionsBuilder. E.g. options

creating 1-1 relationship between two class using code first and migration

∥☆過路亽.° 提交于 2019-12-25 07:00:13
问题 Well, it is 1st time i am trying to create 1-1 relationship between two tables using code first. I took some help online and come across the following classes mapping. Than I ran migration and found something wrong. E.g. The migration says that primary key for StudentDetails is Id from Student table whereas I am looking to have primary key StudentId. Also, the foreign key is being created in opposite way. Please can someone highlight what is wrong here or is it me who perceived it wrong. I

How to change string key to int

十年热恋 提交于 2019-12-25 04:22:43
问题 I use C# EntityFramework and CodeFirst. Also I use migrations (automatic & manual migrations). I have a model - public class MyClass { public string Key { set; get; } public string Something { set; get; } } And I already have a database with rows. Now I want to change the model : a. Change "Key" column to "Name" (which is not a problem with migration, especially automatic migrations) b. Add a new property - an int "Key" that will be identity (1, 2, 3...). How can I do that without deleting

'Update-Database' in EF 4.3 code-first - Value cannot be null

只谈情不闲聊 提交于 2019-12-25 03:52:25
问题 Using asp.NET MVC3, I am creating trying to create an abstract class/model with the following: namespace core.Models.Concrete { public class item { [Key] public Guid id { get; set; } public Type ConcreteType { get; set; } public itemtype Type { get; set; } public string barcode { get; set; } public int rating { get; set; } public string Title { get; set; } } } public enum itemtype { Game, Book, Film } Which is used by: namespace core.Models.Abstract { public class game : item { public

Switching to artificial key with different type in Entity Framework Migrations

半世苍凉 提交于 2019-12-25 02:59:48
问题 I'm working on an Entity Framework Code First project where, previously, I had a class with a field called "Id" that was a string type and using the hash. That's specified like this: [Key] public string Id { get; set; } That's no longer what I need because with updates I can now have duplicate values, so I want to change it to look like this: [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int Id { get; set; } [Required] [Index] public string Hash { get; set; } //This represents

How to recover from Entity Framework nightmare - database already has tables with the same name

我只是一个虾纸丫 提交于 2019-12-24 21:00:29
问题 How do you get EF back in Sync with code without losing data when Update-database returns the following message Error Message: System.Data.SqlClient.SqlException (0x80131904): There is already an object named '' in the database. 回答1: I originally wrote this as a self-answering question as I had struggled with the proble for some time, as had a few colleagues, but unfortunately, my answer was deleted and I can't recover it. Since it's a situation that I suspect can happen several times as

WebSecurity.InitializeDatabaseConnection doesn't cooperate with code first migrations

家住魔仙堡 提交于 2019-12-24 14:27:07
问题 In my project I use WebSecurity and EF code first migrations. I have my custom UserProfile class I want to combine with WebSecurity. I want to seed users in migrations' Configuration class in Seed method. So I try this: #1) if (!Roles.RoleExists("admin")) Roles.CreateRole("admin"); if (!WebSecurity.UserExists(AdminUserName)) WebSecurity.CreateUserAndAccount( AdminUserName, "admin", new {Email = "admin@mindmap.pl"}); But it complains that I should call WebSecurity.InitializeDatabaseConnection