seeding

EF Core 2.1 HasData() creating deletes and re-inserts for unchanged entities on subsequent migrations

好久不见. 提交于 2019-12-23 14:38:08
问题 Update 8/29/18 Seeing this issue in inline new -ing of seed data as well. Opened an EF Core issue. Will update the question with any findings. I am trying to use EF Core 2.1's seeding mechanism. However, I want to load the seed data from json flat files rather than hard-coding new C# objects. I wrote the extension method below, which worked well for the initial migration. It looks for files named [MyEntity].json in DataPath and deserializes them into objects. The problem is that if I add a

Rails Seed-Fu Writer why seed got commented out?

前提是你 提交于 2019-12-23 02:38:27
问题 So, here's my custom rake task: task :backup => :environment do |t| SeedFu::Writer.write('/path/to/file.rb', class_name: 'Category', constraints: [:id] do |w| Category.all.each do |x| w << x end end end And the following result file contains: # DO NOT MODIFY THIS FILE, it was auto-generated. # # Date: 2014-06-15 21:08:13 +0700 # Seeding Category # Written with the command: # # /home/dave/.rvm/gems/ruby-2.1.2/bin/rake backup # Category.seed(:id, #<Category id: 1, name: "foo">, #<Category id: 2

Python Libtorrent doesn't seed

对着背影说爱祢 提交于 2019-12-23 01:44:20
问题 I'm trying to generate a torrent and seed it with python libtorrent, it generates the torrent, but doesn't seed it. I am using libtorrent-0.16.18 with Python3.4 on Ubuntu 14.04 import sys import time import libtorrent as lt fs = lt.file_storage() lt.add_files(fs, "./test.txt") t = lt.create_torrent(fs) t.add_tracker("udp://tracker.publicbt.com:80") t.set_creator("My Torrent") t.set_comment("Test") lt.set_piece_hashes(t, ".") torrent = t.generate() f = open("mytorrent.torrent", "wb") f.write

How to create a new record for a many-to-many through association that accepts nested attributes?

冷暖自知 提交于 2019-12-22 10:24:05
问题 Organization and User have a many-to-many association through Relationship . Initially I implemented this a 1-to-many association, which worked but now I need it to become a many-to-many through association. So I created the Relationship model and changed the association in the model files. Organization accepts nested attributes for User as in my app I have a joined signup form for the two. Also, I use it in my seeds file: Organization.create!(name: "name", ...).users.create(email: "email

Sequelize: seed with associations

纵然是瞬间 提交于 2019-12-21 04:23:07
问题 I have 2 models, Courses and Videos, for example. And Courses has many Videos. // course.js 'use strict'; module.exports = (sequelize, DataTypes) => { const Course = sequelize.define('Course', { title: DataTypes.STRING, description: DataTypes.STRING }); Course.associate = models => { Course.hasMany(models.Video); }; return Course; }; // video.js 'use strict'; module.exports = (sequelize, DataTypes) => { const Video = sequelize.define('Video', { title: DataTypes.STRING, description: DataTypes

Constructors on classes extending Eloquent

依然范特西╮ 提交于 2019-12-20 17:35:43
问题 I just started a new website and I wanted to make use of Eloquent. In the process of seeding my database, I noticed that I would get empty rows added if I had included any kind of constructor on the model that extends eloquent. For example, running this seeder: <?php class TeamTableSeeder extends Seeder { public function run() { DB::table('tm_team')->delete(); Team::create(array( 'city' => 'Minneapolis', 'state' => 'MN', 'country' => 'USA', 'name' => 'Twins' ) ); Team::create(array( 'city' =>

invalid byte sequence in US-ASCII (Argument Error) when I run rake db:seed in Rails

这一生的挚爱 提交于 2019-12-18 10:01:36
问题 When I run rake db:seed in my Rails app, I'm getting this error: invalid byte sequence in US-ASCII (Argument Error) I just added science_majors and down to my seed file, and now when I run rake db:seed it gives me this error: invalid byte sequence error Why is this, and how can I fix it? part of seeds.rb @college = College.find_or_create_by_name!('University of Pittsburgh') if @college.update_attributes( url: 'university-of-pittsburgh', public: 'Public', years: '4-year', category: 'National

How to Seed Users and Roles with Code First Migration using Identity ASP.NET Core

ぃ、小莉子 提交于 2019-12-17 17:29:13
问题 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 : IdentityDbContext<ApplicationUser> { protected override void OnModelCreating(ModelBuilder builder) { // On event model creating base.OnModelCreating(builder); } } Please note ApplicationDbContext use IdentityDbContext and not DbContext. There is any IdentityConfig.cs. Where i need to put the classic

What does the integer while setting the seed mean?

醉酒当歌 提交于 2019-12-13 11:34:21
问题 I want to randomly select n rows from my data set using the sample() function in R . I was getting different outputs each time and hence used set.seed() function to get the same output. I know that each integer in the set.seed() will give me a unique output and the output will be the same if set the same seed. But I'm not able to make out what that integer that is passed as a parameter to the set.seed() function means. Is it just an index that goes into the random generator algorithm or does

Seeding data will not work when schema changes with Code First when using migrations

我是研究僧i 提交于 2019-12-13 08:53:21
问题 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 works. UNTIL I normalize out a table and then try to seed it I get a primary key error. Basically in my context when I uncomment out the changes in the 'TODO' section and the schema changes I get a primary key violation when attempting population of the newly normalized out table. It will work for