0

Have a database table with more than 1000 records (eg city). Is there any method or Exporter, what would translate it in code-first.

PS To create through code- first small plate is still possible, but large (100,500) for a long time ....

1 Answer 1

0

You can easily reverse engineer the whole model into pure POCO model, aka Code-Firs model, with a few clicks. You need to install MySQL connector .NET from here. Be sure to read this first in order not to get into pesky exceptions. There are some mishaps with different versions of MySQL server password store model and mysql connector but they are resolvable.

When you are finished installing :

  1. Open your project.
  2. Right-click your csproj
  3. Add new item
  4. Choose "Data" from the left pane.
  5. Choose "ADO.NET Entity Data Model"
  6. then in the wizard choose "Code first from database"
  7. then if you did the installation of MySQL Connector as prescribed you will be able to connect to your server, select all the table you want and VS will create a model for you. Be sure to install the latest MySQL connector because only there every MySQL type is supported. Some previous versions does not support everything and exception will be thrown.

When you are done a pure code entity model class which derives from DbContext will be created.

Sign up to request clarification or add additional context in comments.

8 Comments

Yes, it works (I also watched this msdn.microsoft.com/ru-ru/data/jj200620) ... Is there any way you take the seeds from the base? Automatically enumeration to write long ....
how to take a enumeration to the database created in Code first////
db.Set<Note>().AddRange(myEnumerable).SaveChanges();
that's not what I wanted .... I would like to record from the database converted to enum
Sorry, but I do not understand what "to record from the database converted to enum" actually means. Do you mean to transform a single row from the DB to IEnumerable<object>?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.