All Questions
Tagged with seeding ef-code-first
15 questions
0
votes
1
answer
992
views
EF Core Migration - PK Violation when seeding data
I am working with an existing project that has a database with what appears to be manually created data via SQL Server \ SSMS.
Further down the project someone else has come and created a seed data \...
0
votes
1
answer
476
views
Seeding method is inserting additional Entities with NULL values
I am having this strange behavior all of a sudden (i have compared my files in version control (tfs) to be sure i did not change anything and i didn't found anything different).
I am seeding my ...
0
votes
1
answer
97
views
Entity Framework: Populating a many-to-many relationship with existing data (seed)
In my Code-First database i have a many-to-many relationship between the object "Question" and the object "Section", which is noted as follows:
In Section:
public List<Question> Questions { ...
0
votes
1
answer
111
views
Update-database with code first and foreign key that's required not working
When using code first i have this scenario:
I have an existing database where tables are created with Code first.
Know suddenly there needs to be a change in the program and there is a new table ...
5
votes
0
answers
659
views
How to generate SQL script from code first seeding?
As I am unable to use the migrate.exe tool to update the database, I am creating migration SQL scripts, and applying them manually, which works perfectly.
As the seed part is not included into the ...
10
votes
1
answer
5k
views
Entity Framework - Seed AddOrUpdate with multi column index as identifier
I am trying to seed a database using the context.AddOrUpdate method, but the problem is that I need to make the inserted data unique based on a multi column index.
[Table("climbing_grades")]
public ...
1
vote
0
answers
88
views
EF6 Seed Data Incorrect on first pass
I am using EF6 code first to push my model to a database. Everything is working great in terms of creating the database and it does execute the seed commands as expected. The problem is that some of ...
73
votes
12
answers
101k
views
How to Seed Users and Roles with Code First Migration using Identity ASP.NET Core
I have created a new clean asp.net 5 project (rc1-final). Using Identity Authentication I just have the ApplicationDbContext.cs with the following code:
public class ApplicationDbContext : ...
0
votes
1
answer
223
views
Seeding data will not work when schema changes with Code First when using migrations
Okay so I am using Entity Framework 6.1 and attempting code first with seeding. I have a drop always intializer that ALWAYS WORKS. However I want to use database migration which I have set up and it ...
117
votes
6
answers
127k
views
EntityType 'IdentityUserLogin' has no key defined. Define the key for this EntityType
I am working with Entity Framework Code First and MVC 5. When I created my application with Individual User Accounts Authentication I was given an Account controller and along with it all the required ...
0
votes
1
answer
188
views
EF Data Migrations - Schema changes successfully applied but no data seed occurring?
I have an initial create in my migrations folder alongside a subsequent migration file. When I run Update-Database -ProjectName Data -StartUpProjectName Ui -Script from the Package Manager Console I ...
1
vote
0
answers
97
views
Why can't I seed a user using EF 6 Code First?
Like the title says, I'm using Entity Framework 6. When I call Update-Database, the seed method fails:
SimpleMembershipProvider userMgr = new SimpleMembershipProvider();
if (WebSecurity.Initialized)
...
0
votes
1
answer
173
views
Entity Framework: Seeding data from the business layer
I am using Entity Framework 6, and code first. I have a Data, Bus, App layers. I wan to seed my data from the business layer, without coupling it onto the Data layer.
The reason I would like to do it ...
1
vote
2
answers
7k
views
Entity Framework - implementing one-to-many foreign key relationship in Seed() method
I have the following classes:
Landlord
[Table("Landlord")]
public class Landlord : UserProfile
{
public static int LandlordProfileViews { get; set; }
// A Landlord can have many ...
0
votes
1
answer
243
views
Entity Framework - seeding database - does PK need to be included in Seed method?
Following the MVC Music Store tutorial, the database is seeded with sample data. The Album class is as follows:
namespace MvcMusicStore.Models
{
public class Album
{
public int ...